changeset 7874:650330db2f99 HEAD

mail_index_view_sync_begin() code cleanup.
author Timo Sirainen <tss@iki.fi>
date Tue, 17 Jun 2008 10:25:55 +0300
parents af9d5fd1071c
children 8ded6c06bcfc
files src/lib-index/mail-index-view-sync.c
diffstat 1 files changed, 7 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-view-sync.c	Tue Jun 17 10:20:54 2008 +0300
+++ b/src/lib-index/mail-index-view-sync.c	Tue Jun 17 10:25:55 2008 +0300
@@ -156,16 +156,13 @@
 	const void *data;
 	unsigned int count, expunge_count = 0;
 	uint32_t prev_seq = 0;
-	bool reset;
 	int ret;
 
-	if (view_sync_set_log_view_range(view, TRUE, &reset) < 0)
-		return -1;
-
 	/* get a list of expunge transactions. there may be some that we have
 	   already synced, but it doesn't matter because they'll get dropped
 	   out when converting to sequences */
 	i_array_init(expunges_r, 64);
+	mail_transaction_log_view_mark(view->log_view);
 	while ((ret = mail_transaction_log_view_next(view->log_view,
 						     &hdr, &data)) > 0) {
 		if ((hdr->type & MAIL_TRANSACTION_EXPUNGE) == 0)
@@ -183,6 +180,7 @@
 			break;
 		}
 	}
+	mail_transaction_log_view_rewind(view->log_view);
 
 	if (ret < 0) {
 		array_free(expunges_r);
@@ -319,6 +317,11 @@
 		return ctx;
 	}
 
+	if (view_sync_set_log_view_range(view, sync_expunges, &reset) < 0) {
+		ctx->failed = TRUE;
+		return ctx;
+	}
+
 	if (sync_expunges) {
 		/* get list of all expunges first */
 		if (view_sync_get_expunges(view, &ctx->expunges,
@@ -328,11 +331,6 @@
 		}
 	}
 
-	if (view_sync_set_log_view_range(view, sync_expunges, &reset) < 0) {
-		ctx->failed = TRUE;
-		return ctx;
-	}
-
 	ctx->finish_min_msg_count = reset ? 0 :
 		view->map->hdr.messages_count - expunge_count;
 	mail_index_sync_map_init(&ctx->sync_map_ctx, view,