changeset 21253:ba5c04b9457b

lib-storage: Add struct mail_save_context.copy_src_mail
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 24 Nov 2016 20:40:15 +0200
parents 8868574cd88c
children a29415ef148d
files src/lib-storage/mail-storage-private.h src/lib-storage/mail-storage.c
diffstat 2 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/mail-storage-private.h	Wed Nov 30 02:17:12 2016 +0200
+++ b/src/lib-storage/mail-storage-private.h	Thu Nov 24 20:40:15 2016 +0200
@@ -643,6 +643,10 @@
 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;
--- a/src/lib-storage/mail-storage.c	Wed Nov 30 02:17:12 2016 +0200
+++ b/src/lib-storage/mail-storage.c	Thu Nov 24 20:40:15 2016 +0200
@@ -2265,7 +2265,9 @@
 	}
 
 	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 @@
 		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() */