]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Add struct mail_save_context.copy_src_mail
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 24 Nov 2016 18:40:15 +0000 (20:40 +0200)
committerGitLab <gitlab@git.dovecot.net>
Wed, 30 Nov 2016 13:21:38 +0000 (15:21 +0200)
src/lib-storage/mail-storage-private.h
src/lib-storage/mail-storage.c

index 5a74327ceef0111328fa717e634b11b0d9f65d8d..c91a447c2aed7b38636b51a1d9540986c222a45b 100644 (file)
@@ -635,6 +635,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;
index fa39e51939d95c8eba1f0cbd0f36a8869202cd37..73f8b46a533a514d9fa3a24138dbe9716381ac44 100644 (file)
@@ -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() */