From: Timo Sirainen Date: Wed, 18 Jan 2012 14:51:22 +0000 (+0200) Subject: lib-storage: Preserve from_envelope in save context's dest_mail even if it's temporary. X-Git-Tag: 2.1.rc4~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8dc3747de75e2bf208f0f2dbdbae4a279b5ee6f;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Preserve from_envelope in save context's dest_mail even if it's temporary. This allows looking it up while the mail is being saved. --- diff --git a/src/lib-storage/index/index-mail.c b/src/lib-storage/index/index-mail.c index 85aef6f049..7712d97bed 100644 --- a/src/lib-storage/index/index-mail.c +++ b/src/lib-storage/index/index-mail.c @@ -1077,6 +1077,9 @@ int index_mail_get_special(struct mail *_mail, *value_r = data->envelope; return 0; case MAIL_FETCH_FROM_ENVELOPE: + *value_r = data->from_envelope != NULL ? + data->from_envelope : ""; + return 0; case MAIL_FETCH_UIDL_FILE_NAME: case MAIL_FETCH_UIDL_BACKEND: case MAIL_FETCH_SEARCH_RELEVANCY: @@ -1749,3 +1752,16 @@ int index_mail_opened(struct mail *mail ATTR_UNUSED, { return 0; } + +void index_mail_save_finish(struct mail_save_context *ctx) +{ + struct index_mail *imail = (struct index_mail *)ctx->dest_mail; + + if (imail == NULL) + return; + + if (ctx->from_envelope != NULL && imail->data.from_envelope == NULL) { + imail->data.from_envelope = + p_strdup(imail->data_pool, ctx->from_envelope); + } +} diff --git a/src/lib-storage/index/index-mail.h b/src/lib-storage/index/index-mail.h index 30bbcefe0a..869dff9e70 100644 --- a/src/lib-storage/index/index-mail.h +++ b/src/lib-storage/index/index-mail.h @@ -78,6 +78,7 @@ struct index_mail_data { struct message_part *parts; const char *envelope, *body, *bodystructure, *uid_string, *guid; + const char *from_envelope; struct message_part_envelope_data *envelope_data; uint32_t seq; @@ -235,5 +236,6 @@ void index_mail_cache_parse_deinit(struct mail *mail, time_t received_date, int index_mail_cache_lookup_field(struct index_mail *mail, buffer_t *buf, unsigned int field_idx); +void index_mail_save_finish(struct mail_save_context *ctx); #endif diff --git a/src/lib-storage/index/index-storage.c b/src/lib-storage/index/index-storage.c index 14e3a14660..181c7b124d 100644 --- a/src/lib-storage/index/index-storage.c +++ b/src/lib-storage/index/index-storage.c @@ -606,6 +606,7 @@ bool index_storage_is_inconsistent(struct mailbox *box) void index_save_context_free(struct mail_save_context *ctx) { + index_mail_save_finish(ctx); i_free_and_null(ctx->from_envelope); i_free_and_null(ctx->guid); i_free_and_null(ctx->pop3_uidl); @@ -698,4 +699,3 @@ int index_storage_set_subscribed(struct mailbox *box, bool set) } return 0; } -