From 0f41e91d411fdfbd517a2c2a8f76bdaeb9b0ae47 Mon Sep 17 00:00:00 2001 From: Roberto Ricci Date: Tue, 9 Nov 2021 16:09:12 +0100 Subject: [PATCH] cmd/ncdu: display correct path in delete confirmation dialog If the remote on the command line is "remote:subdir", when deleting "filename", the confirmation message shows the path "remote:subdirfilename". Using fspath.JoinRootPath() fixes this. Also use this function and fs.ConfigString() in other parts of the file, since they are more appropriate. --- cmd/ncdu/ncdu.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/ncdu/ncdu.go b/cmd/ncdu/ncdu.go index 6359184b5..4ef08f346 100644 --- a/cmd/ncdu/ncdu.go +++ b/cmd/ncdu/ncdu.go @@ -19,6 +19,7 @@ import ( "github.com/rclone/rclone/cmd" "github.com/rclone/rclone/cmd/ncdu/scan" "github.com/rclone/rclone/fs" + "github.com/rclone/rclone/fs/fspath" "github.com/rclone/rclone/fs/operations" "github.com/spf13/cobra" ) @@ -529,7 +530,7 @@ func (u *UI) delete() { } u.popupBox([]string{ "Delete this file?", - u.fsName + dirEntry.String()}) + fspath.JoinRootPath(u.fsName, dirEntry.String())}) } else { u.boxMenuHandler = func(f fs.Fs, p string, o int) (string, error) { if o != 1 { @@ -548,7 +549,7 @@ func (u *UI) delete() { u.popupBox([]string{ "Purge this directory?", "ALL files in it will be deleted", - u.fsName + dirEntry.String()}) + fspath.JoinRootPath(u.fsName, dirEntry.String())}) } } @@ -659,7 +660,7 @@ func (u *UI) sortCurrentDir() { func (u *UI) setCurrentDir(d *scan.Dir) { u.d = d u.entries = d.Entries() - u.path = path.Join(u.fsName, d.Path()) + u.path = fspath.JoinRootPath(u.fsName, d.Path()) u.sortCurrentDir() } @@ -742,7 +743,7 @@ func NewUI(f fs.Fs) *UI { f: f, path: "Waiting for root...", dirListHeight: 20, // updated in Draw - fsName: f.Name() + ":" + f.Root(), + fsName: fs.ConfigString(f), showGraph: true, showCounts: false, showDirAverageSize: false,