# HG changeset patch # User Timo Sirainen # Date 1287071584 -3600 # Node ID a3e40c6b14fe7f93511c7cd6785235af7b983def # Parent 03ac8057710d8dd9eb82d8b01c13b4c8122412dc lib-storage: If mailbox deletion failed, we crashed while trying to write undelete record to index. diff -r 03ac8057710d -r a3e40c6b14fe src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Thu Oct 14 16:22:54 2010 +0100 +++ b/src/lib-storage/mail-storage.c Thu Oct 14 16:53:04 2010 +0100 @@ -669,8 +669,10 @@ int mailbox_mark_index_deleted(struct mailbox *box, bool del) { + struct mail_index_transaction *trans; enum mail_index_transaction_flags trans_flags = 0; - struct mail_index_transaction *trans; + 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 @@ 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)