aboutsummaryrefslogtreecommitdiff
path: root/commands
diff options
context:
space:
mode:
authorJason Cox <me@jasoncarloscox.com>2024-01-09 09:18:01 -0500
committerRobin Jarry <robin@jarry.cc>2024-01-17 12:03:00 +0100
commit216ef0736b3defd2cecc9ff6ae049f70c01975b3 (patch)
treefdd7d0181391cd450f21b3dba2eeb598df7f34ca /commands
parentec8b22b8eec40a745978547f296c2ab3ad2a5569 (diff)
downloadaerc-216ef0736b3defd2cecc9ff6ae049f70c01975b3.tar.gz
aerc-216ef0736b3defd2cecc9ff6ae049f70c01975b3.zip
rmdir: allow removing non-empty query dirs
Notmuch query directories aren't backed by a filesystem directory, so deleting them doesn't actually delete any messages. Allow removing such directories even when they aren't empty to avoid the need to use the somewhat scary -f flag. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Reviewed-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'commands')
-rw-r--r--commands/account/rmdir.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/commands/account/rmdir.go b/commands/account/rmdir.go
index 1afeb15d..8bf4d6b2 100644
--- a/commands/account/rmdir.go
+++ b/commands/account/rmdir.go
@@ -27,15 +27,18 @@ func (r RemoveDir) Execute(args []string) error {
return errors.New("No account selected")
}
+ var role models.Role
+ if d := acct.Directories().SelectedDirectory(); d != nil {
+ role = d.Role
+ }
+
// Check for any messages in the directory.
- if !acct.Messages().Empty() && !r.Force {
+ if role != models.QueryRole && !acct.Messages().Empty() && !r.Force {
return errors.New("Refusing to remove non-empty directory; use -f")
}
- if d := acct.Directories().SelectedDirectory(); d != nil {
- if d.Role == models.VirtualRole {
- return errors.New("Cannot remove a virtual node")
- }
+ if role == models.VirtualRole {
+ return errors.New("Cannot remove a virtual node")
}
curDir := acct.SelectedDirectory()