]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Allow mailbox_mark_index_deleted() to be called multiple times within...
authorTimo Sirainen <tss@iki.fi>
Tue, 24 Aug 2010 16:00:39 +0000 (17:00 +0100)
committerTimo Sirainen <tss@iki.fi>
Tue, 24 Aug 2010 16:00:39 +0000 (17:00 +0100)
src/lib-storage/mail-storage-private.h
src/lib-storage/mail-storage.c

index 3f32677fd54dee60e257fe8e008fd7c515cbbf80..68e640e5d9ebb0b6d0944f4fa32b6119002df350 100644 (file)
@@ -268,6 +268,8 @@ struct mailbox {
        unsigned int backend_readonly:1;
        /* Mailbox is being deleted */
        unsigned int deleting:1;
+       /* Mailbox was already marked as deleted within this allocation. */
+       unsigned int marked_deleted:1;
        /* TRUE if this is an INBOX for this user */
        unsigned int inbox_user:1;
        /* TRUE if this is an INBOX for this namespace (user or shared) */
index 9e810c350e4bd46559476587f5c49068cce5baf4..f1bdc5095fe37330ecb55b9d6dabdd4ce00e848e 100644 (file)
@@ -669,6 +669,12 @@ int mailbox_mark_index_deleted(struct mailbox *box, bool del)
        enum mail_index_transaction_flags trans_flags = 0;
        struct mail_index_transaction *trans;
 
+       if (box->marked_deleted && del) {
+               /* we already marked it deleted. this allows plugins to
+                  "lock" the deletion earlier. */
+               return 0;
+       }
+
        trans_flags = del ? 0 : MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL;
        trans = mail_index_transaction_begin(box->view, trans_flags);
        if (del)
@@ -683,7 +689,11 @@ int mailbox_mark_index_deleted(struct mailbox *box, bool del)
        /* sync the mailbox. this finishes the index deletion and it can
           succeed only for a single session. we do it here, so the rest of
           the deletion code doesn't have to worry about race conditions. */
-       return mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ);
+       if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ) < 0)
+               return -1;
+
+       box->marked_deleted = del;
+       return 0;
 }
 
 static bool mailbox_try_undelete(struct mailbox *box)