aboutsummaryrefslogtreecommitdiffstats
path: root/commands/account
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2023-11-18 01:39:45 +0100
committerRobin Jarry <robin@jarry.cc>2023-11-23 00:14:54 +0100
commit019a1a5813fc30440fb8c552b9e03dfe8d5d5d17 (patch)
tree0aa2d5be0736d183fe823a281f6e4fc58a6b997f /commands/account
parent30d28d0542997ad55a59439775929c63b2de8616 (diff)
downloadaerc-019a1a5813fc30440fb8c552b9e03dfe8d5d5d17.tar.gz
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 <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'commands/account')
-rw-r--r--commands/account/rmdir.go6
1 files changed, 5 insertions, 1 deletions
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()
}
})
})