Mercurial > dovecot > core-2.2
changeset 14618:344bd3d47ced
imap MOVE: Don't commit expunge transaction before the copy transaction has succeeded.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 20 Jun 2012 06:32:06 +0300 |
parents | c14c58bedafe |
children | 73ee8d00888d |
files | src/imap/cmd-copy.c |
diffstat | 1 files changed, 13 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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, ©_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;