[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-save.c, 1.94.2.11, 1.94.2.12

tss at dovecot.org tss at dovecot.org
Wed Apr 25 16:30:35 EEST 2007


Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv2877

Modified Files:
      Tag: branch_1_0
	mbox-save.c 
Log Message:
If pop3_uidl_format=%m, it wasn't cached correctly when saving new messages
(eg. with deliver). X-Delivery-ID wasn't used in the MD5 sum, causing
duplicates when POP3 recalculated the MD5 sum later.



Index: mbox-save.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-save.c,v
retrieving revision 1.94.2.11
retrieving revision 1.94.2.12
diff -u -d -r1.94.2.11 -r1.94.2.12
--- mbox-save.c	11 Mar 2007 16:27:52 -0000	1.94.2.11
+++ mbox-save.c	25 Apr 2007 13:30:32 -0000	1.94.2.12
@@ -370,6 +370,21 @@
 	str_append(ctx->headers, "X-Delivery-ID: ");
 	base64_encode(md5_result, sizeof(md5_result), ctx->headers);
 	str_append_c(ctx->headers, '\n');
+
+	if (ctx->mbox_md5_ctx != NULL) {
+		struct message_header_line hdr;
+
+		memset(&hdr, 0, sizeof(hdr));
+		hdr.name = "X-Delivery-ID";
+		hdr.name_len = strlen(hdr.name);
+		hdr.middle = (const unsigned char *)": ";
+		hdr.middle_len = 2;
+		hdr.value = hdr.full_value = str_data(ctx->headers) +
+			hdr.name_len + hdr.middle_len;
+		hdr.value_len = hdr.full_value_len = str_len(ctx->headers) -
+			(hdr.name_len + hdr.middle_len + 1);
+		mbox_md5_continue(ctx->mbox_md5_ctx, &hdr);
+	}
 	t_pop();
 }
 
@@ -413,6 +428,8 @@
 	save_flags = (flags & ~MAIL_RECENT) | MAIL_RECENT;
 	str_truncate(ctx->headers, 0);
 	if (ctx->synced) {
+		if (ctx->mbox->mbox_save_md5)
+			ctx->mbox_md5_ctx = mbox_md5_init();
 		if (ctx->output->offset == 0) {
 			/* writing the first mail. Insert X-IMAPbase as well. */
 			str_printfa(ctx->headers, "X-IMAPbase: %u %010u\n",
@@ -477,8 +494,6 @@
 			 MAIL_STORAGE_FLAG_SAVE_CRLF) != 0 ?
 			o_stream_create_crlf(default_pool, ctx->output) :
 			o_stream_create_lf(default_pool, ctx->output);
-		if (ctx->mbox->mbox_save_md5 && ctx->synced)
-			ctx->mbox_md5_ctx = mbox_md5_init();
 	}
 
 	*ctx_r = &ctx->ctx;



More information about the dovecot-cvs mailing list