dovecot-2.0: lib-storage: If mailbox deletion failed, we crashed...

dovecot at dovecot.org dovecot at dovecot.org
Thu Oct 14 18:53:08 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/a3e40c6b14fe
changeset: 12264:a3e40c6b14fe
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Oct 14 16:53:04 2010 +0100
description:
lib-storage: If mailbox deletion failed, we crashed while trying to write undelete record to index.

diffstat:

 src/lib-storage/mail-storage.c |  11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diffs (29 lines):

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)


More information about the dovecot-cvs mailing list