From: Timo Sirainen Date: Mon, 27 Feb 2017 12:21:48 +0000 (+0200) Subject: doveadm move: Use mailbox_move() instead of copy+expunge X-Git-Tag: 2.3.0.rc1~1988 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6ebe7a974a5b32dd3f2d5f4f08d22aa993283e65;p=thirdparty%2Fdovecot%2Fcore.git doveadm move: Use mailbox_move() instead of copy+expunge This allows for some optimizations to be done. --- diff --git a/src/doveadm/doveadm-mail-copymove.c b/src/doveadm/doveadm-mail-copymove.c index 2cc2f5b6e7..0b927ecf5b 100644 --- a/src/doveadm/doveadm-mail-copymove.c +++ b/src/doveadm/doveadm-mail-copymove.c @@ -29,7 +29,7 @@ cmd_copy_box(struct copy_cmd_context *ctx, struct mailbox *destbox, 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 @@ cmd_copy_box(struct copy_cmd_context *ctx, struct mailbox *destbox, 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);