]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Don't autocreate mailbox during deletion.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 26 Jun 2017 16:44:43 +0000 (19:44 +0300)
committerGitLab <gitlab@git.dovecot.net>
Wed, 28 Jun 2017 14:57:07 +0000 (17:57 +0300)
Trying to delete a nonexistent autocreated mailbox first created it and then
immediately deleted it.

src/lib-storage/index/index-storage.c
src/lib-storage/mail-storage.c

index c0d241707ea657e5c1893a3165dae89252334282..449d186e4836ac5f9a79ed54d4e85e76488da842 100644 (file)
@@ -700,7 +700,15 @@ int index_storage_mailbox_delete_pre(struct mailbox *box)
 
        if (!box->opened) {
                /* \noselect mailbox, try deleting only the directory */
-               return index_storage_mailbox_delete_dir(box, FALSE);
+               if (index_storage_mailbox_delete_dir(box, FALSE) == 0)
+                       return 0;
+               if (mailbox_is_autocreated(box)) {
+                       /* Return success when trying to delete autocreated
+                          mailbox. The client sees it as existing, so we
+                          shouldn't be returning an error. */
+                       return 0;
+               }
+               return -1;
        }
 
        if ((box->list->flags & MAILBOX_LIST_FLAG_MAILBOX_FILES) == 0) {
index fb5b6aa003ceed532a1e4fe419b047f0ada47cae..df89b209f483b316b6e8710482603865eb93f448 100644 (file)
@@ -1181,6 +1181,7 @@ mailbox_open_full(struct mailbox *box, struct istream *input)
        } T_END;
 
        if (ret < 0 && box->storage->error == MAIL_ERROR_NOTFOUND &&
+           !box->deleting &&
            box->input == NULL && mailbox_is_autocreated(box)) T_BEGIN {
                ret = mailbox_autocreate_and_reopen(box);
        } T_END;
@@ -1527,7 +1528,7 @@ int mailbox_delete(struct mailbox *box)
                if (mailbox_get_last_mail_error(box) != MAIL_ERROR_NOTFOUND &&
                    !box->mailbox_deleted)
                        return -1;
-               /* \noselect mailbox */
+               /* might be a \noselect mailbox, so continue deletion */
        }
 
        ret = box->v.delete_box(box);