changeset 5124:e008f09dc3c9 HEAD

When saving a message to an empty mbox file, write X-IMAPbase header so the UID doesn't change.
author Timo Sirainen <tss@iki.fi>
date Wed, 14 Feb 2007 20:23:18 +0200
parents 2d21b5020994
children 0b7be87efd7c
files src/lib-storage/index/mbox/mbox-save.c
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/mbox-save.c	Tue Feb 13 21:37:01 2007 +0200
+++ b/src/lib-storage/index/mbox/mbox-save.c	Wed Feb 14 20:23:18 2007 +0200
@@ -36,7 +36,7 @@
 
 	string_t *headers;
 	size_t space_end_idx;
-	uint32_t seq, next_uid;
+	uint32_t seq, next_uid, uid_validity;
 
 	struct istream *input;
 	struct ostream *output, *body_output;
@@ -199,6 +199,7 @@
 	hdr = mail_index_get_header(view);
 
 	ctx->next_uid = hdr->next_uid;
+	ctx->uid_validity = hdr->uid_validity;
 	ctx->synced = TRUE;
         t->mbox_modified = TRUE;
 
@@ -387,6 +388,11 @@
 	save_flags = (flags & ~MAIL_RECENT) | MAIL_RECENT;
 	str_truncate(ctx->headers, 0);
 	if (ctx->synced) {
+		if (ctx->output->offset == 0) {
+			/* writing the first mail. Insert X-IMAPbase as well. */
+			str_printfa(ctx->headers, "X-IMAPbase: %u %010u\n",
+				    ctx->uid_validity, ctx->next_uid);
+		}
 		str_printfa(ctx->headers, "X-UID: %u\n", ctx->next_uid);
 		if (!mbox->ibox.keep_recent)
 			save_flags &= ~MAIL_RECENT;