]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
FS layout: When deleting a mailbox, don't give an error if mailbox has children.
authorTimo Sirainen <tss@iki.fi>
Fri, 16 Dec 2011 11:08:18 +0000 (13:08 +0200)
committerTimo Sirainen <tss@iki.fi>
Fri, 16 Dec 2011 11:08:18 +0000 (13:08 +0200)
The mailbox got successfully deleted, but it still gave an error.

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

index 77000cc723a7154e20a1eaeaee87d041965066e0..7673f6339bb5be6a5f70f81109407d6e2764e509 100644 (file)
@@ -511,6 +511,7 @@ int index_storage_mailbox_delete(struct mailbox *box)
 {
        struct mailbox_metadata metadata;
        struct mailbox_status status;
+       enum mail_error error;
        int ret_guid;
 
        if (!box->opened) {
@@ -564,7 +565,14 @@ int index_storage_mailbox_delete(struct mailbox *box)
                                        MAILBOX_LOG_RECORD_DELETE_MAILBOX,
                                        metadata.guid);
        }
-       return index_storage_mailbox_delete_dir(box, TRUE);
+       if (index_storage_mailbox_delete_dir(box, TRUE) < 0) {
+               (void)mailbox_get_last_error(box, &error);
+               if (error != MAIL_ERROR_EXISTS)
+                       return -1;
+               /* we deleted the mailbox, but couldn't delete the directory
+                  because it has children. that's not an error. */
+       }
+       return 0;
 }
 
 int index_storage_mailbox_rename(struct mailbox *src, struct mailbox *dest,