changeset 6511:fe5c19ffc119 HEAD

Sync mbox when committing transaction only when saving messages to update last-uid.
author Timo Sirainen <tss@iki.fi>
date Sun, 30 Sep 2007 16:57:32 +0300
parents d79975141df2
children 1a3604c8ee05
files src/lib-storage/index/mbox/mbox-save.c src/lib-storage/index/mbox/mbox-storage.h src/lib-storage/index/mbox/mbox-transaction.c
diffstat 3 files changed, 7 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/mbox-save.c	Sun Sep 30 16:45:36 2007 +0300
+++ b/src/lib-storage/index/mbox/mbox-save.c	Sun Sep 30 16:57:32 2007 +0300
@@ -199,7 +199,7 @@
 	ctx->first_saved_uid = ctx->next_uid;
 	ctx->uid_validity = hdr->uid_validity;
 	ctx->synced = TRUE;
-	t->mbox_modified = TRUE;
+	t->mails_saved = TRUE;
 
 	mail_index_view_close(&view);
 }
--- a/src/lib-storage/index/mbox/mbox-storage.h	Sun Sep 30 16:45:36 2007 +0300
+++ b/src/lib-storage/index/mbox/mbox-storage.h	Sun Sep 30 16:57:32 2007 +0300
@@ -56,7 +56,7 @@
 
 	struct mbox_save_context *save_ctx;
 	unsigned int mbox_lock_id;
-	unsigned int mbox_modified:1;
+	unsigned int mails_saved:1;
 };
 
 extern struct mail_vfuncs mbox_mail_vfuncs;
--- a/src/lib-storage/index/mbox/mbox-transaction.c	Sun Sep 30 16:45:36 2007 +0300
+++ b/src/lib-storage/index/mbox/mbox-transaction.c	Sun Sep 30 16:57:32 2007 +0300
@@ -16,14 +16,12 @@
 	struct mbox_transaction_context *mt = MAIL_STORAGE_CONTEXT(t);
 	struct mbox_mailbox *mbox = (struct mbox_mailbox *)mt->ictx.ibox;
 	unsigned int lock_id = mt->mbox_lock_id;
-	enum mailbox_sync_flags flags = mt->ictx.commit_flags;
-	bool mbox_modified;
-	bool syncing = t->sync_transaction;
+	bool mails_saved;
 	int ret = 0;
 
 	if (mt->save_ctx != NULL)
 		ret = mbox_transaction_save_commit(mt->save_ctx);
-	mbox_modified = mt->mbox_modified;
+	mails_saved = mt->mails_saved;
 
 	if (ret < 0)
 		index_transaction_finish_rollback(&mt->ictx);
@@ -42,18 +40,9 @@
 		lock_id = 0;
 	}
 
-	if (ret == 0 && !syncing) {
-		enum mbox_sync_flags mbox_sync_flags = MBOX_SYNC_LAST_COMMIT;
-		if ((flags & MAILBOX_SYNC_FLAG_FULL_READ) != 0 &&
-		    !mbox->mbox_very_dirty_syncs)
-			mbox_sync_flags |= MBOX_SYNC_UNDIRTY;
-		if ((flags & MAILBOX_SYNC_FLAG_FULL_WRITE) != 0)
-			mbox_sync_flags |= MBOX_SYNC_REWRITE;
-		if (mbox_modified) {
-			/* after saving mails we want to update the last-uid */
-			mbox_sync_flags |= MBOX_SYNC_HEADER | MBOX_SYNC_REWRITE;
-		}
-		if (mbox_sync(mbox, mbox_sync_flags) < 0)
+	if (ret == 0 && mails_saved) {
+		/* after saving mails we want to update the last-uid */
+		if (mbox_sync(mbox, MBOX_SYNC_HEADER | MBOX_SYNC_REWRITE) < 0)
 			ret = -1;
 	}