From: Timo Sirainen Date: Thu, 24 Nov 2016 18:40:15 +0000 (+0200) Subject: lib-storage: Add struct mail_save_context.copy_src_mail X-Git-Tag: 2.2.27~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9d86be5b636bcbf6297c2d00bce672ea6e8e4bc3;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Add struct mail_save_context.copy_src_mail --- diff --git a/src/lib-storage/mail-storage-private.h b/src/lib-storage/mail-storage-private.h index e82c61f559..dcbfa9bf64 100644 --- a/src/lib-storage/mail-storage-private.h +++ b/src/lib-storage/mail-storage-private.h @@ -643,6 +643,10 @@ struct mail_save_data { struct mail_save_context { struct mailbox_transaction_context *transaction; struct mail *dest_mail; + /* Set during mailbox_copy(). This is useful when copying is + implemented via save, and the save_*() methods want to access the + source mail. */ + struct mail *copy_src_mail; /* data that changes for each saved mail */ struct mail_save_data data; diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index fa39e51939..73f8b46a53 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -2265,7 +2265,9 @@ static int mailbox_copy_int(struct mail_save_context **_ctx, struct mail *mail) } i_assert(!ctx->copying_or_moving); + i_assert(ctx->copy_src_mail == NULL); ctx->copying_or_moving = TRUE; + ctx->copy_src_mail = mail; ctx->finishing = TRUE; T_BEGIN { ret = t->box->v.copy(ctx, backend_mail); @@ -2280,6 +2282,7 @@ static int mailbox_copy_int(struct mail_save_context **_ctx, struct mail *mail) mailbox_keywords_unref(&keywords); i_assert(!ctx->unfinished); + ctx->copy_src_mail = NULL; ctx->copying_via_save = FALSE; ctx->copying_or_moving = FALSE; ctx->saving = FALSE; /* if we came from mailbox_save_using_mail() */