dovecot-2.1: dbox: Index rebuild now preserves caching decisions.

dovecot at dovecot.org dovecot at dovecot.org
Thu Feb 9 01:23:16 EET 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/d8d214cc1936
changeset: 14084:d8d214cc1936
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Feb 09 01:23:00 2012 +0200
description:
dbox: Index rebuild now preserves caching decisions.

diffstat:

 src/lib-storage/index/dbox-common/dbox-sync-rebuild.c    |  10 ++++++++++
 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c |   3 ---
 src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c   |   2 --
 3 files changed, 10 insertions(+), 5 deletions(-)

diffs (59 lines):

diff -r 21c3ce1b21cd -r d8d214cc1936 src/lib-storage/index/dbox-common/dbox-sync-rebuild.c
--- a/src/lib-storage/index/dbox-common/dbox-sync-rebuild.c	Thu Feb 09 01:21:41 2012 +0200
+++ b/src/lib-storage/index/dbox-common/dbox-sync-rebuild.c	Thu Feb 09 01:23:00 2012 +0200
@@ -2,6 +2,7 @@
 
 #include "lib.h"
 #include "array.h"
+#include "mail-cache.h"
 #include "mail-index-modseq.h"
 #include "mailbox-list-private.h"
 #include "index-storage.h"
@@ -159,6 +160,12 @@
 	index_mailbox_reset_uidvalidity(box);
 	mail_index_ext_lookup(box->index, "cache", &ctx->cache_ext_id);
 
+	/* open cache and read the caching decisions. we'll reset the cache in
+	   case it contains any invalid data, but we want to preserve the
+	   decisions. */
+	(void)mail_cache_open_and_verify(ctx->box->cache);
+	mail_cache_reset(box->cache);
+
 	/* if backup index file exists, try to use it */
 	index_dir = mailbox_list_get_path(box->list, box->name,
 					  MAILBOX_LIST_PATH_TYPE_INDEX);
@@ -183,6 +190,9 @@
 	struct dbox_sync_rebuild_context *ctx = *_ctx;
 
 	*_ctx = NULL;
+
+	/* initialize cache file with the old field decisions */
+	(void)mail_cache_compress(ctx->box->cache, ctx->trans);
 	dbox_sync_rebuild_header(ctx);
 	if (ctx->backup_index != NULL) {
 		mail_index_view_close(&ctx->backup_view);
diff -r 21c3ce1b21cd -r d8d214cc1936 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
--- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c	Thu Feb 09 01:21:41 2012 +0200
+++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c	Thu Feb 09 01:23:00 2012 +0200
@@ -501,9 +501,6 @@
 		return -1;
 	}
 
-	/* reset cache, just in case it contains invalid data */
-	mail_cache_reset(box->cache);
-
 	rebuild_ctx = dbox_sync_index_rebuild_init(&mbox->box, view, trans);
 	mdbox_header_update(rebuild_ctx, mbox);
 	rebuild_mailbox_multi(ctx, rebuild_ctx, mbox, view, trans);
diff -r 21c3ce1b21cd -r d8d214cc1936 src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c
--- a/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c	Thu Feb 09 01:21:41 2012 +0200
+++ b/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c	Thu Feb 09 01:23:00 2012 +0200
@@ -195,8 +195,6 @@
 		return -1;
 	}
 
-	mail_cache_reset(mbox->box.cache);
-
 	view = mail_index_view_open(mbox->box.index);
 	trans = mail_index_transaction_begin(view,
 					MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL);


More information about the dovecot-cvs mailing list