From: Timo Sirainen Date: Sun, 26 Feb 2017 12:32:44 +0000 (+0200) Subject: lazy-expunge: Use mailbox_move() instead of mailbox_copy() X-Git-Tag: 2.3.0.rc1~1992 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f05d013c67c9af853c3258d59403da13e1d4307b;p=thirdparty%2Fdovecot%2Fcore.git lazy-expunge: Use mailbox_move() instead of mailbox_copy() This allows some optimizations to be performed that are only possible when moving messages. It's slightly strange now that mail_expunge() is triggered twice for the same source mail, but lazy_expunge plugin is called very early so most plugins won't see it called twice. Currently only acl plugin sees it, and it doesn't care. --- diff --git a/src/plugins/lazy-expunge/lazy-expunge-plugin.c b/src/plugins/lazy-expunge/lazy-expunge-plugin.c index 3c10d5366b..3eda8268f8 100644 --- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c +++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c @@ -30,6 +30,7 @@ struct lazy_expunge_mail { union mail_module_context module_ctx; bool moving; + bool recursing; }; struct lazy_expunge_mail_user { @@ -288,6 +289,10 @@ static void lazy_expunge_mail_expunge(struct mail *_mail) if (lt->delayed_error != MAIL_ERROR_NONE) return; + if (mmail->recursing) { + mmail->module_ctx.super.expunge(_mail); + return; + } /* Clear this in case the mail is used for non-move later on. */ mmail->moving = FALSE; @@ -344,9 +349,11 @@ static void lazy_expunge_mail_expunge(struct mail *_mail) save_ctx = mailbox_save_alloc(lt->dest_trans); mailbox_save_copy_flags(save_ctx, _mail); save_ctx->data.flags &= ~MAIL_DELETED; - if (mailbox_copy(&save_ctx, _mail) < 0 && !_mail->expunged) + + mmail->recursing = TRUE; + if (mailbox_move(&save_ctx, _mail) < 0 && !_mail->expunged) lazy_expunge_set_error(lt, lt->dest_box->storage); - mmail->module_ctx.super.expunge(_mail); + mmail->recursing = FALSE; } static int lazy_expunge_copy(struct mail_save_context *ctx, struct mail *_mail)