From 019a1a5813fc30440fb8c552b9e03dfe8d5d5d17 Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Sat, 18 Nov 2023 01:39:45 +0100 Subject: rmdir: back to current folder upon error Jump back to the current folder consistently when encountering an error. This has only been partly implemented. For example, when you try to remove a notmuch folder, the remove operation will fail because it is unsupported. However, you would end up in a different directory because a directoy change is done before trying to remove the current folder. If this happens make sure you end up in the current directory again. Fixes: a35d9bab4664 ("rmdir: ensure proper sequence of operations") Signed-off-by: Koni Marti Acked-by: Robin Jarry --- commands/account/rmdir.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'commands/account') diff --git a/commands/account/rmdir.go b/commands/account/rmdir.go index 0793c7b8..1afeb15d 100644 --- a/commands/account/rmdir.go +++ b/commands/account/rmdir.go @@ -81,13 +81,15 @@ func (r RemoveDir) Execute(args []string) error { return errors.New("No directory to move to afterwards!") } + reopenCurrentDir := func() { acct.Directories().Open(curDir, 0, nil) } + acct.Directories().Open(newDir, 0, func(msg types.WorkerMessage) { switch msg.(type) { case *types.Done: break case *types.Error: app.PushError("Could not change directory") - acct.Directories().Open(curDir, 0, nil) + reopenCurrentDir() return default: return @@ -101,8 +103,10 @@ func (r RemoveDir) Execute(args []string) error { app.PushStatus("Directory removed.", 10*time.Second) case *types.Error: app.PushError(msg.Error.Error()) + reopenCurrentDir() case *types.Unsupported: app.PushError(":rmdir is not supported by the backend.") + reopenCurrentDir() } }) }) -- cgit