dovecot: Cache everything interesting while saving a message.

dovecot at dovecot.org dovecot at dovecot.org
Thu Jul 19 05:52:35 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/a019240a9df1
changeset: 6104:a019240a9df1
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jul 19 05:52:22 2007 +0300
description:
Cache everything interesting while saving a message.

diffstat:

1 file changed, 14 insertions(+), 7 deletions(-)
src/lib-storage/index/mbox/mbox-save.c |   21 ++++++++++++++-------

diffs (66 lines):

diff -r 15f845e16a91 -r a019240a9df1 src/lib-storage/index/mbox/mbox-save.c
--- a/src/lib-storage/index/mbox/mbox-save.c	Thu Jul 19 05:37:19 2007 +0300
+++ b/src/lib-storage/index/mbox/mbox-save.c	Thu Jul 19 05:52:22 2007 +0300
@@ -346,11 +346,6 @@ static void save_header_callback(struct 
 	if ((hdr == NULL && ctx->eoh_input_offset == (uoff_t)-1) ||
 	    (hdr != NULL && hdr->eoh))
 		ctx->eoh_input_offset = ctx->input->v_offset;
-
-	if (ctx->mail != NULL) {
-		index_mail_parse_header(NULL, hdr,
-					(struct index_mail *)ctx->mail);
-	}
 }
 
 static void mbox_save_x_delivery_id(struct mbox_save_context *ctx)
@@ -458,8 +453,6 @@ int mbox_save_init(struct mailbox_transa
 		}
 		if (mail_set_seq(dest_mail, ctx->seq) < 0)
 			i_unreached();
-		index_mail_parse_header_init((struct index_mail *)dest_mail,
-					     NULL);
 	}
 	mbox_save_append_flag_headers(ctx->headers, save_flags);
 	mbox_save_append_keyword_headers(ctx, keywords);
@@ -486,6 +479,12 @@ int mbox_save_init(struct mailbox_transa
 			 MAIL_STORAGE_FLAG_SAVE_CRLF) != 0 ?
 			o_stream_create_crlf(default_pool, ctx->output) :
 			o_stream_create_lf(default_pool, ctx->output);
+		if (ctx->mail != NULL) {
+			input = index_mail_cache_parse_init(ctx->mail,
+							    ctx->input);
+			i_stream_unref(&ctx->input);
+			ctx->input = input;
+		}
 	}
 
 	*ctx_r = &ctx->ctx;
@@ -513,6 +512,9 @@ int mbox_save_continue(struct mail_save_
 				return write_error(ctx);
 			ctx->last_char = data[size-1];
 			i_stream_skip(ctx->input, size);
+
+			if (ctx->mail != NULL)
+				index_mail_cache_parse_continue(ctx->mail);
 		}
 
 		if (ctx->last_char != '\n') {
@@ -547,6 +549,9 @@ int mbox_save_continue(struct mail_save_
 			return write_error(ctx);
 		ctx->last_char = data[size-1];
 		i_stream_skip(ctx->input, size);
+
+		if (ctx->mail != NULL)
+			index_mail_cache_parse_continue(ctx->mail);
 	}
 
 	if (ctx->last_char != '\n') {
@@ -604,6 +609,8 @@ int mbox_save_finish(struct mail_save_co
 		t_pop();
 	}
 
+	if (ctx->mail != NULL)
+		index_mail_cache_parse_deinit(ctx->mail);
 	if (ctx->input != NULL)
 		i_stream_destroy(&ctx->input);
 	if (ctx->body_output != NULL)


More information about the dovecot-cvs mailing list