Mercurial > dovecot > core-2.2
changeset 21707:6441d69cdfb6
doveadm move: Use mailbox_move() instead of copy+expunge
This allows for some optimizations to be done.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Mon, 27 Feb 2017 14:21:48 +0200 |
parents | 1c0256d2c33e |
children | a7295bb1a998 |
files | src/doveadm/doveadm-mail-copymove.c |
diffstat | 1 files changed, 8 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/doveadm/doveadm-mail-copymove.c Mon Feb 27 09:39:06 2017 +0200 +++ b/src/doveadm/doveadm-mail-copymove.c Mon Feb 27 14:21:48 2017 +0200 @@ -29,7 +29,7 @@ struct mailbox_transaction_context *desttrans; struct mail_save_context *save_ctx; struct mail *mail; - int ret = 0; + int ret = 0, ret2; if (doveadm_mail_iter_init(&ctx->ctx, info, ctx->ctx.search_args, 0, NULL, FALSE, &iter) < 0) @@ -44,11 +44,13 @@ while (doveadm_mail_iter_next(iter, &mail)) { save_ctx = mailbox_save_alloc(desttrans); mailbox_save_copy_flags(save_ctx, mail); - if (mailbox_copy(&save_ctx, mail) == 0) { - if (ctx->move) - mail_expunge(mail); - } else { - i_error("Copying message UID %u from '%s' failed: %s", + if (ctx->move) + ret2 = mailbox_move(&save_ctx, mail); + else + ret2 = mailbox_copy(&save_ctx, mail); + if (ret2 < 0) { + i_error("%s message UID %u from '%s' failed: %s", + ctx->move ? "Moving" : "Copying", mail->uid, info->vname, mailbox_get_last_error(destbox, NULL)); doveadm_mail_failed_mailbox(&ctx->ctx, destbox);