]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Preserve from_envelope in save context's dest_mail even if it's temporary.
authorTimo Sirainen <tss@iki.fi>
Wed, 18 Jan 2012 14:51:22 +0000 (16:51 +0200)
committerTimo Sirainen <tss@iki.fi>
Wed, 18 Jan 2012 14:51:22 +0000 (16:51 +0200)
This allows looking it up while the mail is being saved.

src/lib-storage/index/index-mail.c
src/lib-storage/index/index-mail.h
src/lib-storage/index/index-storage.c

index 85aef6f0494a47c144db97444f5e0e7d6bf02c0c..7712d97bed1de39aaacb955c2d41935f3b602735 100644 (file)
@@ -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);
+       }
+}
index 30bbcefe0a18148d7640a4af5b250d4b43d83685..869dff9e70f51d69cee3427e20f04bf9779b18ed 100644 (file)
@@ -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
index 14e3a14660f5f89e04c031fce6efdd047eb76367..181c7b124d3b229f73fff628513b53b50740b9a4 100644 (file)
@@ -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;
 }
-