diff src/lib-storage/index/dbox-common/dbox-sync-rebuild.c @ 10844:3bfb1e9f556b HEAD

dbox index rebuild: Fixed setting next-uid and highest-modseq.
author Timo Sirainen <tss@iki.fi>
date Sat, 06 Mar 2010 13:11:07 +0200
parents 154f52b7a6fd
children cf302ede55bc
line wrap: on
line diff
--- a/src/lib-storage/index/dbox-common/dbox-sync-rebuild.c	Sat Mar 06 12:52:59 2010 +0200
+++ b/src/lib-storage/index/dbox-common/dbox-sync-rebuild.c	Sat Mar 06 13:11:07 2010 +0200
@@ -92,7 +92,10 @@
 static void dbox_sync_rebuild_header(struct dbox_sync_rebuild_context *ctx)
 {
 	const struct mail_index_header *hdr, *backup_hdr;
+	struct mail_index *index = mail_index_view_get_index(ctx->view);
+	struct mail_index_modseq_header modseq_hdr;
 	uint32_t uid_validity, next_uid;
+	uint64_t modseq;
 
 	hdr = mail_index_get_header(ctx->view);
 	backup_hdr = ctx->backup_view == NULL ? NULL :
@@ -118,16 +121,18 @@
 		next_uid = dbox_get_uidvalidity_next(ctx->box->list);
 	mail_index_update_header(ctx->trans,
 				 offsetof(struct mail_index_header, next_uid),
-				 &next_uid, sizeof(next_uid), TRUE);
+				 &next_uid, sizeof(next_uid), FALSE);
 
 	/* set highest-modseq */
-	mail_index_update_highest_modseq(ctx->trans,
-		mail_index_modseq_get_highest(ctx->view));
+	memset(&modseq_hdr, 0, sizeof(modseq_hdr));
+	modseq_hdr.highest_modseq = mail_index_modseq_get_highest(ctx->view);
 	if (ctx->backup_view != NULL) {
-		mail_index_update_highest_modseq(ctx->trans,
-			mail_index_modseq_get_highest(ctx->backup_view));
-
+		modseq = mail_index_modseq_get_highest(ctx->backup_view);
+		if (modseq_hdr.highest_modseq < modseq)
+			modseq_hdr.highest_modseq = modseq;
 	}
+	mail_index_update_header_ext(ctx->trans, index->modseq_ext_id,
+				     0, &modseq_hdr, sizeof(modseq_hdr));
 }
 
 struct dbox_sync_rebuild_context *