Unexpected behavior of doveadm mailbox delete -e -s
John Fawcett
john at voipsupport.it
Sun Dec 13 18:23:37 EET 2020
On 13/12/2020 05:59, Mar Alegre wrote:
> Hello,
>
> I have encountered what I believe to be a bug, or at least inaccurate
> documentation. I am running version 2.3.4.1 of Dovecot (installed via
> the default repo for Debian 10), so my apologies if this has been
> fixed in a more recent version. I tried to look for changelogs but was
> not able to find any.
>
> The `doveadm mailbox delete` command accepts flags `-e` and `-s`
> (among others). The flags are described by both the man pages and the
> wiki as follows:
>
> - `-e`: Require mailboxes to be empty before deleting.
> - `-s`: Unsubscribe deleted mailboxes.
>
> Based on these descriptions, I would expect that when both of these
> flags are combined, a directory that is not empty would be neither
> deleted nor unsubscribed. However, I have discovered that when I run
> the command `doveadm mailbox delete -u $myusername -e -s
> $non_empty_dir`, the result is that the directory is not deleted, but
> it *is* unsubscribed.
>
> I assume this is a bug, but if it is intended, the documentation
> should probably be updated to more clearly communicate that the `-s`
> flag will cause a directory to be unsubscribed even if it is not deleted.
>
> Best,
> Mar Alegre
Hopefully this will fix the issue, allowing the unsubscribe to go ahead
only if the delete did not return an error (<0). There are some cases,
namely mailbox not open, in which 0 is returned without deleting the
mailbox (autocreated mailboxes) or the delete is done without checking
for an empty mailbox, but I guess those are not relevant when calling
the delete from doveadm, though I may be wrong on that.
--- doveadm/doveadm-mail-mailbox.c.orig 2020-12-13 16:58:59.589077259
+0100
+++ doveadm/doveadm-mail-mailbox.c 2020-12-13 17:00:28.326194491 +0100
@@ -383,7 +383,7 @@
doveadm_mail_failed_mailbox(_ctx, box);
ret = -1;
}
- if (ctx->ctx.subscriptions) {
+ if (ret2>=0 && ctx->ctx.subscriptions) {
if (mailbox_set_subscribed(box, FALSE) < 0) {
i_error("Can't unsubscribe mailbox %s: %s", name,
mail_storage_get_last_internal_error(storage, NULL));
More information about the dovecot
mailing list