]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Mailbox deletion: Delay marking its index deleted until ACL has had a chance to abort...
authorTimo Sirainen <tss@iki.fi>
Mon, 7 Jun 2010 13:05:42 +0000 (14:05 +0100)
committerTimo Sirainen <tss@iki.fi>
Mon, 7 Jun 2010 13:05:42 +0000 (14:05 +0100)
--HG--
branch : HEAD

src/lib-storage/index/index-storage.c
src/lib-storage/mail-storage-private.h
src/lib-storage/mail-storage.c
src/plugins/lazy-expunge/lazy-expunge-plugin.c

index 119dabb8fbf136f1b223baa45f0da1ebda723569..aaa0d1409c3b6b2d49cba42e9cf20ca003210a40 100644 (file)
@@ -462,6 +462,9 @@ int index_storage_mailbox_delete(struct mailbox *box)
                return index_storage_mailbox_delete_dir(box, FALSE);
        }
 
+       if (mailbox_mark_index_deleted(box, TRUE) < 0)
+               return -1;
+
        if (mailbox_get_guid(box, mailbox_guid) < 0)
                return -1;
 
index 27fbdafa65e43270eb2698d84e8b1c080030925f..c951b5bbd642302c1a04cfa88e4347e0e822b51d 100644 (file)
@@ -463,6 +463,7 @@ void mail_storage_copy_list_error(struct mail_storage *storage,
 int mail_set_aborted(struct mail *mail);
 void mail_set_expunged(struct mail *mail);
 void mailbox_set_deleted(struct mailbox *box);
+int mailbox_mark_index_deleted(struct mailbox *box, bool del);
 void mailbox_refresh_permissions(struct mailbox *box);
 
 /* Returns -1 if error, 0 if failed with EEXIST, 1 if ok */
index 2ac68de2daa89a5a4bde05e44e4f852364dc5a7d..fc428581124064f7d05c526f41c80b043f38c155 100644 (file)
@@ -664,7 +664,7 @@ int mailbox_update(struct mailbox *box, const struct mailbox_update *update)
        return box->v.update(box, update);
 }
 
-static int mailbox_mark_index_deleted(struct mailbox *box, bool del)
+int mailbox_mark_index_deleted(struct mailbox *box, bool del)
 {
        enum mail_index_transaction_flags trans_flags = 0;
        struct mail_index_transaction *trans;
@@ -737,10 +737,6 @@ int mailbox_delete(struct mailbox *box)
                }
        }
 
-       if (box->opened) {
-               if (mailbox_mark_index_deleted(box, TRUE) < 0)
-                       return -1;
-       }
        ret = box->v.delete(box);
 
        box->deleting = FALSE;
index 784def5d1d7918b4585ad7f0a14c7616143b8369..9513d23d67764cc6458e0854117b1f8980b9662a 100644 (file)
@@ -373,8 +373,11 @@ static int lazy_expunge_mailbox_delete(struct mailbox *box)
        char timestamp[256];
        int ret;
 
-       if (llist->internal_namespace)
+       if (llist->internal_namespace || !box->opened) {
+               /* a) deleting mailbox from lazy_expunge namespaces
+                  b) deleting a \noselect mailbox */
                return lbox->super.delete(box);
+       }
 
        expunge_ns = get_lazy_ns(list->ns->user, LAZY_NAMESPACE_EXPUNGE);
        dest_ns = get_lazy_ns(list->ns->user, LAZY_NAMESPACE_DELETE);
@@ -393,7 +396,11 @@ static int lazy_expunge_mailbox_delete(struct mailbox *box)
                destname = t_strconcat(box->name, "-", timestamp, NULL);
        }
 
-       /* first move the actual mailbox */
+       /* avoid potential race conditions by marking it deleted */
+       if (mailbox_mark_index_deleted(box, TRUE) < 0)
+               return -1;
+
+       /* rename it into the lazy_expunge namespace */
        ret = mailbox_move(box, dest_ns->list, destname, &expunge_box);
        if (ret < 0)
                return -1;