Mercurial > dovecot > core-2.2
changeset 21701:2e9671812460
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.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Sun, 26 Feb 2017 14:32:44 +0200 |
parents | 28e2d0186a42 |
children | 23398ba09ac2 |
files | src/plugins/lazy-expunge/lazy-expunge-plugin.c |
diffstat | 1 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c Fri Feb 24 12:27:02 2017 +0200 +++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c Sun Feb 26 14:32:44 2017 +0200 @@ -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 @@ 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 @@ 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)