dovecot-2.2: imap MOVE: Don't commit expunge transaction before ...

dovecot at dovecot.org dovecot at dovecot.org
Wed Jun 20 06:32:16 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/344bd3d47ced
changeset: 14618:344bd3d47ced
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jun 20 06:32:06 2012 +0300
description:
imap MOVE: Don't commit expunge transaction before the copy transaction has succeeded.

diffstat:

 src/imap/cmd-copy.c |  24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

diffs (62 lines):

diff -r c14c58bedafe -r 344bd3d47ced src/imap/cmd-copy.c
--- a/src/imap/cmd-copy.c	Wed Jun 20 06:21:57 2012 +0300
+++ b/src/imap/cmd-copy.c	Wed Jun 20 06:32:06 2012 +0300
@@ -30,6 +30,7 @@
 
 static int fetch_and_copy(struct client *client, bool move,
 			  struct mailbox_transaction_context *t,
+			  struct mailbox_transaction_context **src_trans_r,
 			  struct mail_search_args *search_args,
 			  const char **src_uidset_r,
 			  unsigned int *copy_count_r)
@@ -79,14 +80,7 @@
 	if (mailbox_search_deinit(&search_ctx) < 0)
 		ret = -1;
 
-	if (ret <= 0 && move) {
-		/* move failed, don't expunge anything */
-		mailbox_transaction_rollback(&src_trans);
-	} else {
-		if (mailbox_transaction_commit(&src_trans) < 0)
-			ret = -1;
-	}
-
+	*src_trans_r = src_trans;
 	*src_uidset_r = str_c(src_uidset);
 	*copy_count_r = copy_count;
 	return ret;
@@ -97,7 +91,7 @@
 	struct client *client = cmd->client;
 	struct mail_storage *dest_storage;
 	struct mailbox *destbox;
-	struct mailbox_transaction_context *t;
+	struct mailbox_transaction_context *t, *src_trans;
         struct mail_search_args *search_args;
 	const char *messageset, *mailbox, *src_uidset;
 	enum mailbox_sync_flags sync_flags = 0;
@@ -126,7 +120,7 @@
 	t = mailbox_transaction_begin(destbox,
 				      MAILBOX_TRANSACTION_FLAG_EXTERNAL |
 				      MAILBOX_TRANSACTION_FLAG_ASSIGN_UIDS);
-	ret = fetch_and_copy(client, move, t, search_args,
+	ret = fetch_and_copy(client, move, t, &src_trans, search_args,
 			     &src_uidset, &copy_count);
 	mail_search_args_unref(&search_args);
 
@@ -156,7 +150,15 @@
 		pool_unref(&changes.pool);
 	}
 
-	dest_storage = mailbox_get_storage(destbox);
+	if (ret <= 0 && move) {
+		/* move failed, don't expunge anything */
+		mailbox_transaction_rollback(&src_trans);
+	} else {
+		if (mailbox_transaction_commit(&src_trans) < 0)
+			ret = -1;
+	}
+
+ 	dest_storage = mailbox_get_storage(destbox);
 	if (destbox != client->mailbox) {
 		sync_flags |= MAILBOX_SYNC_FLAG_FAST;
 		imap_flags |= IMAP_SYNC_FLAG_SAFE;


More information about the dovecot-cvs mailing list