changeset 2685:52352a5859e4 HEAD

When we had dirty messages, we kept resyncing the whole mailbox constantly.
author Timo Sirainen <tss@iki.fi>
date Mon, 04 Oct 2004 19:31:51 +0300
parents 7979984b6276
children 6e0a7083a880
files src/lib-index/mail-index-sync-private.h src/lib-index/mail-index-sync.c src/lib-index/mail-index.h src/lib-storage/index/maildir/maildir-sync.c src/lib-storage/index/mbox/mbox-sync.c
diffstat 5 files changed, 13 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-sync-private.h	Sun Oct 03 20:03:27 2004 +0300
+++ b/src/lib-index/mail-index-sync-private.h	Mon Oct 04 19:31:51 2004 +0300
@@ -22,6 +22,7 @@
 	unsigned int lock_id;
 
 	unsigned int sync_appends:1;
+	unsigned int sync_dirty:1;
 };
 
 struct mail_index_sync_map_ctx {
--- a/src/lib-index/mail-index-sync.c	Sun Oct 03 20:03:27 2004 +0300
+++ b/src/lib-index/mail-index-sync.c	Mon Oct 04 19:31:51 2004 +0300
@@ -202,7 +202,8 @@
 	size_t size;
 	int ret;
 
-	if (ctx->view->map->hdr->flags & MAIL_INDEX_HDR_FLAG_HAVE_DIRTY) {
+	if ((ctx->view->map->hdr->flags & MAIL_INDEX_HDR_FLAG_HAVE_DIRTY) &&
+	    ctx->sync_dirty) {
 		/* show dirty flags as flag updates */
 		if (mail_index_sync_add_dirty_updates(ctx) < 0)
 			return -1;
@@ -248,7 +249,7 @@
                           struct mail_index_sync_ctx **ctx_r,
 			  struct mail_index_view **view_r,
 			  uint32_t log_file_seq, uoff_t log_file_offset,
-			  int sync_recent)
+			  int sync_recent, int sync_dirty)
 {
 	struct mail_index_sync_ctx *ctx;
 	uint32_t seq;
@@ -279,6 +280,7 @@
 	ctx = i_new(struct mail_index_sync_ctx, 1);
 	ctx->index = index;
 	ctx->lock_id = lock_id;
+	ctx->sync_dirty = sync_dirty;
 
 	ctx->view = mail_index_view_open(index);
 	ctx->view->external = TRUE;
--- a/src/lib-index/mail-index.h	Sun Oct 03 20:03:27 2004 +0300
+++ b/src/lib-index/mail-index.h	Mon Oct 04 19:31:51 2004 +0300
@@ -207,7 +207,7 @@
 			  struct mail_index_sync_ctx **ctx_r,
 			  struct mail_index_view **view_r,
 			  uint32_t log_file_seq, uoff_t log_file_offset,
-			  int sync_recent);
+			  int sync_recent, int sync_dirty);
 /* Returns -1 if error, 0 if sync is finished, 1 if record was filled. */
 int mail_index_sync_next(struct mail_index_sync_ctx *ctx,
 			 struct mail_index_sync_rec *sync_rec);
--- a/src/lib-storage/index/maildir/maildir-sync.c	Sun Oct 03 20:03:27 2004 +0300
+++ b/src/lib-storage/index/maildir/maildir-sync.c	Mon Oct 04 19:31:51 2004 +0300
@@ -337,7 +337,7 @@
         ibox->syncing_commit = TRUE;
 	ret = mail_index_sync_begin(ibox->index, &ctx.sync_ctx, &ctx.view,
 				    ibox->commit_log_file_seq,
-				    ibox->commit_log_file_offset, FALSE);
+				    ibox->commit_log_file_offset, FALSE, FALSE);
 	if (ret > 0) {
 		ctx.trans = mail_index_transaction_begin(ctx.view, FALSE);
 
@@ -593,7 +593,8 @@
 	sync_ctx.ibox = ibox;
 
 	if (mail_index_sync_begin(ibox->index, &sync_ctx.sync_ctx, &view,
-				  (uint32_t)-1, (uoff_t)-1, FALSE) <= 0) {
+				  (uint32_t)-1, (uoff_t)-1,
+				  FALSE, FALSE) <= 0) {
 		mail_storage_set_index_error(ibox);
 		return -1;
 	}
--- a/src/lib-storage/index/mbox/mbox-sync.c	Sun Oct 03 20:03:27 2004 +0300
+++ b/src/lib-storage/index/mbox/mbox-sync.c	Mon Oct 04 19:31:51 2004 +0300
@@ -1258,7 +1258,8 @@
 	}
 
 	ret = mail_index_sync_begin(ibox->index, &index_sync_ctx, &sync_view,
-				    seq, offset, !ibox->keep_recent);
+				    seq, offset, !ibox->keep_recent,
+				    (flags & MBOX_SYNC_REWRITE) != 0);
 	if (ret <= 0) {
 		if (ret < 0)
 			mail_storage_set_index_error(ibox);
@@ -1351,7 +1352,8 @@
 		ret = mail_index_sync_begin(ibox->index,
 					    &sync_ctx.index_sync_ctx,
 					    &sync_ctx.sync_view,
-					    (uint32_t)-1, (uoff_t)-1, FALSE);
+					    (uint32_t)-1, (uoff_t)-1,
+					    FALSE, FALSE);
 		if (ret < 0)
 			mail_storage_set_index_error(ibox);
 		else {