dovecot-2.2: imapc: Fixed mailbox deletion.

dovecot at dovecot.org dovecot at dovecot.org
Sat Jun 1 03:20:25 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/7af6795f40ed
changeset: 16440:7af6795f40ed
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Jun 01 03:20:15 2013 +0300
description:
imapc: Fixed mailbox deletion.

diffstat:

 src/lib-storage/index/imapc/imapc-storage.c |   8 +++++++-
 src/lib-storage/index/index-storage.c       |  16 +++++++++-------
 src/lib-storage/mail-storage-private.h      |   3 +++
 3 files changed, 19 insertions(+), 8 deletions(-)

diffs (64 lines):

diff -r cd314aa81805 -r 7af6795f40ed src/lib-storage/index/imapc/imapc-storage.c
--- a/src/lib-storage/index/imapc/imapc-storage.c	Sat Jun 01 03:06:54 2013 +0300
+++ b/src/lib-storage/index/imapc/imapc-storage.c	Sat Jun 01 03:20:15 2013 +0300
@@ -666,6 +666,12 @@
 		status_r->permanent_flags = mbox->permanent_flags;
 }
 
+static int imapc_mailbox_delete(struct mailbox *box)
+{
+	box->delete_skip_empty_check = TRUE;
+	return index_storage_mailbox_delete(box);
+}
+
 static int imapc_mailbox_get_status(struct mailbox *box,
 				    enum mailbox_status_items items,
 				    struct mailbox_status *status_r)
@@ -906,7 +912,7 @@
 		index_storage_mailbox_free,
 		imapc_mailbox_create,
 		imapc_mailbox_update,
-		index_storage_mailbox_delete,
+		imapc_mailbox_delete,
 		index_storage_mailbox_rename,
 		imapc_mailbox_get_status,
 		imapc_mailbox_get_metadata,
diff -r cd314aa81805 -r 7af6795f40ed src/lib-storage/index/index-storage.c
--- a/src/lib-storage/index/index-storage.c	Sat Jun 01 03:06:54 2013 +0300
+++ b/src/lib-storage/index/index-storage.c	Sat Jun 01 03:20:15 2013 +0300
@@ -691,13 +691,15 @@
 	if (mailbox_mark_index_deleted(box, TRUE) < 0)
 		return -1;
 
-	if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ) < 0)
-		return -1;
-	mailbox_get_open_status(box, STATUS_MESSAGES, &status);
-	if (status.messages != 0) {
-		mail_storage_set_error(box->storage, MAIL_ERROR_EXISTS,
-			"New mails were added to mailbox during deletion");
-		return -1;
+	if (!box->delete_skip_empty_check || box->deleting_must_be_empty) {
+		if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ) < 0)
+			return -1;
+		mailbox_get_open_status(box, STATUS_MESSAGES, &status);
+		if (status.messages != 0) {
+			mail_storage_set_error(box->storage, MAIL_ERROR_EXISTS,
+				"New mails were added to mailbox during deletion");
+			return -1;
+		}
 	}
 
 	ret_guid = mailbox_get_metadata(box, MAILBOX_METADATA_GUID, &metadata);
diff -r cd314aa81805 -r 7af6795f40ed src/lib-storage/mail-storage-private.h
--- a/src/lib-storage/mail-storage-private.h	Sat Jun 01 03:06:54 2013 +0300
+++ b/src/lib-storage/mail-storage-private.h	Sat Jun 01 03:20:15 2013 +0300
@@ -320,6 +320,9 @@
 	unsigned int deleting:1;
 	/* Delete mailbox only if it's empty */
 	unsigned int deleting_must_be_empty:1;
+	/* The backend wants to skip checking if there are 0 messages before
+	   calling mailbox_list.delete_mailbox() */
+	unsigned int delete_skip_empty_check:1;
 	/* Mailbox was already marked as deleted within this allocation. */
 	unsigned int marked_deleted:1;
 	/* TRUE if this is an INBOX for this user */


More information about the dovecot-cvs mailing list