]> 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)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Tue, 1 Aug 2017 10:40:51 +0000 (13:40 +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 ea81cd433043c1c9b1ef9545e89d70b7180fd694..39d03ebdaa08bd265594c86a4f4df33f19902e55 100644 (file)
@@ -735,7 +735,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 0fb3c6b396c4f94c0a83db61f74f3672d3dc939c..27697e7885e18f7cff3c8d5b7897ca46075fead6 100644 (file)
@@ -1203,6 +1203,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;
@@ -1549,7 +1550,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);