dovecot-2.0: dbox: Figure out internally when message's "physica...

dovecot at dovecot.org dovecot at dovecot.org
Wed May 26 18:16:49 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/e84e72fb1af9
changeset: 11376:e84e72fb1af9
user:      Timo Sirainen <tss at iki.fi>
date:      Wed May 26 16:13:15 2010 +0100
description:
dbox: Figure out internally when message's "physical size" doesn't match "written size".

diffstat:

 src/lib-storage/index/dbox-common/dbox-save.c  |  23 ++++++++++++++---------
 src/lib-storage/index/dbox-common/dbox-save.h  |   2 +-
 src/lib-storage/index/dbox-multi/mdbox-save.c  |   2 +-
 src/lib-storage/index/dbox-single/sdbox-save.c |   3 ++-
 4 files changed, 18 insertions(+), 12 deletions(-)

diffs (89 lines):

diff -r 0c15a760dab8 -r e84e72fb1af9 src/lib-storage/index/dbox-common/dbox-save.c
--- a/src/lib-storage/index/dbox-common/dbox-save.c	Wed May 26 15:29:21 2010 +0100
+++ b/src/lib-storage/index/dbox-common/dbox-save.c	Wed May 26 16:13:15 2010 +0100
@@ -103,11 +103,12 @@
 	ctx->ctx.output = dbox_output;
 }
 
-void dbox_save_write_metadata(struct mail_save_context *ctx,
-			      struct ostream *output,
+void dbox_save_write_metadata(struct mail_save_context *_ctx,
+			      struct ostream *output, uoff_t output_msg_size,
 			      const char *orig_mailbox_name,
 			      uint8_t guid_128[MAIL_GUID_128_SIZE])
 {
+	struct dbox_save_context *ctx = (struct dbox_save_context *)_ctx;
 	struct dbox_metadata_header metadata_hdr;
 	const char *guid;
 	string_t *str;
@@ -119,22 +120,26 @@
 	o_stream_send(output, &metadata_hdr, sizeof(metadata_hdr));
 
 	str = t_str_new(256);
-	if (ctx->saved_physical_size != 0) {
+	if (output_msg_size != ctx->input->v_offset) {
+		/* a plugin changed the data written to disk, so the
+		   "message size" dbox header doesn't contain the actual
+		   "physical" message size. we need to save it as a
+		   separate metadata header. */
 		str_printfa(str, "%c%llx\n", DBOX_METADATA_PHYSICAL_SIZE,
-			    (unsigned long long)ctx->saved_physical_size);
+			    (unsigned long long)ctx->input->v_offset);
 	}
 	str_printfa(str, "%c%lx\n", DBOX_METADATA_RECEIVED_TIME,
-		    (unsigned long)ctx->received_date);
-	if (mail_get_virtual_size(ctx->dest_mail, &vsize) < 0)
+		    (unsigned long)_ctx->received_date);
+	if (mail_get_virtual_size(_ctx->dest_mail, &vsize) < 0)
 		i_unreached();
 	str_printfa(str, "%c%llx\n", DBOX_METADATA_VIRTUAL_SIZE,
 		    (unsigned long long)vsize);
-	if (ctx->pop3_uidl != NULL) {
+	if (_ctx->pop3_uidl != NULL) {
 		str_printfa(str, "%c%s\n", DBOX_METADATA_POP3_UIDL,
-			    ctx->pop3_uidl);
+			    _ctx->pop3_uidl);
 	}
 
-	guid = ctx->guid;
+	guid = _ctx->guid;
 	if (guid != NULL)
 		mail_generate_guid_128_hash(guid, guid_128);
 	else {
diff -r 0c15a760dab8 -r e84e72fb1af9 src/lib-storage/index/dbox-common/dbox-save.h
--- a/src/lib-storage/index/dbox-common/dbox-save.h	Wed May 26 15:29:21 2010 +0100
+++ b/src/lib-storage/index/dbox-common/dbox-save.h	Wed May 26 16:13:15 2010 +0100
@@ -24,7 +24,7 @@
 void dbox_save_end(struct dbox_save_context *ctx);
 
 void dbox_save_write_metadata(struct mail_save_context *ctx,
-			      struct ostream *output,
+			      struct ostream *output, uoff_t output_msg_size,
 			      const char *orig_mailbox_name,
 			      uint8_t guid_128_r[MAIL_GUID_128_SIZE]);
 
diff -r 0c15a760dab8 -r e84e72fb1af9 src/lib-storage/index/dbox-multi/mdbox-save.c
--- a/src/lib-storage/index/dbox-multi/mdbox-save.c	Wed May 26 15:29:21 2010 +0100
+++ b/src/lib-storage/index/dbox-multi/mdbox-save.c	Wed May 26 16:13:15 2010 +0100
@@ -168,7 +168,7 @@
 		mail->append_offset - mail->file_append->file->msg_header_size;
 
 	dbox_save_write_metadata(&ctx->ctx.ctx, ctx->ctx.dbox_output,
-				 ctx->mbox->box.name, guid_128);
+				 message_size, ctx->mbox->box.name, guid_128);
 	/* save the 128bit GUID to index so if the map index gets corrupted
 	   we can still find the message */
 	mail_index_update_ext(ctx->ctx.trans, ctx->ctx.seq,
diff -r 0c15a760dab8 -r e84e72fb1af9 src/lib-storage/index/dbox-single/sdbox-save.c
--- a/src/lib-storage/index/dbox-single/sdbox-save.c	Wed May 26 15:29:21 2010 +0100
+++ b/src/lib-storage/index/dbox-single/sdbox-save.c	Wed May 26 16:13:15 2010 +0100
@@ -116,7 +116,8 @@
 	message_size = ctx->dbox_output->offset -
 		file->msg_header_size - file->file_header_size;
 
-	dbox_save_write_metadata(&ctx->ctx, ctx->dbox_output, NULL, guid_128);
+	dbox_save_write_metadata(&ctx->ctx, ctx->dbox_output,
+				 message_size, NULL, guid_128);
 	dbox_msg_header_fill(&dbox_msg_hdr, message_size);
 	if (o_stream_pwrite(ctx->dbox_output, &dbox_msg_hdr,
 			    sizeof(dbox_msg_hdr),


More information about the dovecot-cvs mailing list