]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: If mailbox deletion failed, we crashed while trying to write undelete...
authorTimo Sirainen <tss@iki.fi>
Thu, 14 Oct 2010 15:53:04 +0000 (16:53 +0100)
committerTimo Sirainen <tss@iki.fi>
Thu, 14 Oct 2010 15:53:04 +0000 (16:53 +0100)
src/lib-storage/mail-storage.c

index eb24af804e961f365f5db094ff4d5d0d164ff7a3..ae4f7a2b318d048ba8c68c7c329080c41ffa2fff 100644 (file)
@@ -669,8 +669,10 @@ int mailbox_update(struct mailbox *box, const struct mailbox_update *update)
 
 int mailbox_mark_index_deleted(struct mailbox *box, bool del)
 {
-       enum mail_index_transaction_flags trans_flags = 0;
        struct mail_index_transaction *trans;
+       enum mail_index_transaction_flags trans_flags = 0;
+       enum mailbox_flags old_flag;
+       int ret;
 
        if (box->marked_deleted && del) {
                /* we already marked it deleted. this allows plugins to
@@ -678,6 +680,13 @@ int mailbox_mark_index_deleted(struct mailbox *box, bool del)
                return 0;
        }
 
+       old_flag = box->flags & MAILBOX_FLAG_OPEN_DELETED;
+       box->flags |= MAILBOX_FLAG_OPEN_DELETED;
+       ret = mailbox_open(box);
+       box->flags = (box->flags & ~MAILBOX_FLAG_OPEN_DELETED) | old_flag;
+       if (ret < 0)
+               return -1;
+
        trans_flags = del ? 0 : MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL;
        trans = mail_index_transaction_begin(box->view, trans_flags);
        if (del)