]> 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)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Sat, 3 Dec 2016 16:45:02 +0000 (18:45 +0200)
src/lib-storage/mail-storage-private.h
src/lib-storage/mail-storage.c

index e82c61f559c4237308edd6ccc3445593d3e7b72d..dcbfa9bf6468304862be1769980c35e7e7578837 100644 (file)
@@ -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;
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() */