changeset 5750:18fb3f1fc41b HEAD

Don't update cache record links if we know it's already been done.
author Timo Sirainen <tss@iki.fi>
date Sat, 16 Jun 2007 00:18:27 +0300
parents 420a386fa27a
children a230272b3f28
files src/lib-index/mail-cache-sync-update.c
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-cache-sync-update.c	Fri Jun 15 23:52:47 2007 +0300
+++ b/src/lib-index/mail-cache-sync-update.c	Sat Jun 16 00:18:27 2007 +0300
@@ -105,7 +105,8 @@
 	struct mail_cache_sync_context *ctx = *context;
 	const uint32_t *old_cache_offset = old_data;
 	const uint32_t *new_cache_offset = new_data;
-	uint32_t cache_file_seq;
+	uint32_t cache_file_seq, cur_seq, tail_seq;
+	uoff_t cur_offset, tail_offset;
 	int ret;
 
 	if (new_cache_offset == NULL) {
@@ -126,8 +127,14 @@
 	    sync_ctx->type == MAIL_INDEX_SYNC_HANDLER_VIEW)
 		return 1;
 
-	/* FIXME: we should do this only once to avoid extra overhead.
-	   currently this can happen multiple times as map is synchronized. */
+	mail_transaction_log_view_get_prev_pos(view->log_view,
+					       &cur_seq, &cur_offset);
+	mail_transaction_log_get_mailbox_sync_pos(view->index->log,
+						  &tail_seq, &tail_offset);
+	if (LOG_IS_BEFORE(cur_seq, cur_offset, tail_seq, tail_offset)) {
+		/* already been linked */
+		return 1;
+	}
 
 	/* we'll need to link the old and new cache records */
 	ret = mail_cache_handler_init(&ctx, cache);