]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Fix mailbox delete to not delete childrens' INDEX or CONTROL dirs
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 30 Jun 2017 10:56:54 +0000 (13:56 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 3 Jul 2017 12:22:51 +0000 (15:22 +0300)
If mail_location had separate INDEX and/or CONTROL set, deleting a mailbox
with children caused the childrens' index and/or control directories to be
deleted (but the mail/ALT directories weren't).

I'm not sure why the _FLAG_MAILBOX_FILES was treated as a special case
earlier. It shouldn't make a difference.

src/lib-storage/list/mailbox-list-delete.c

index 89d1e373537c6210fbabb384316a81b9b37c4acb..c56e8701932ab6e493c4a59247628c597730d332 100644 (file)
@@ -295,8 +295,10 @@ static int mailbox_list_try_delete(struct mailbox_list *list, const char *name,
            strcmp(path, mailbox_path) == 0)
                return 0;
 
-       if (*list->set.maildir_name == '\0' &&
-           (list->flags & MAILBOX_LIST_FLAG_MAILBOX_FILES) == 0) {
+       /* Note that only ALT currently uses maildir_name in paths.
+          INDEX and CONTROL don't. */
+       if (type != MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX ||
+           *list->set.maildir_name == '\0') {
                /* this directory may contain also child mailboxes' data.
                   we don't want to delete that. */
                bool rmdir_path = *list->set.maildir_name != '\0';