diff src/lib-storage/index/mbox/mbox-save.c @ 5240:117c9fd0b633 HEAD

Keep track of the mbox dirty state better. Also when moving mails inside an mbox without changing the file's size, make sure the file's mtime changes even if it means sleeping for a second.
author Timo Sirainen <tss@iki.fi>
date Wed, 07 Mar 2007 17:38:24 +0200
parents 5dfa745c0622
children 2712ba108fba
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/mbox-save.c	Wed Mar 07 17:34:58 2007 +0200
+++ b/src/lib-storage/index/mbox/mbox-save.c	Wed Mar 07 17:38:24 2007 +0200
@@ -300,13 +300,15 @@
 				return -1;
 		}
 
-		if (!want_mail) {
-			/* assign UIDs only if mbox doesn't require syncing */
-			ret = mbox_sync_has_changed(mbox, TRUE);
-			if (ret < 0)
-				return -1;
-			if (ret == 0)
-				mbox_save_init_sync(t);
+		/* update mbox_sync_dirty state */
+		ret = mbox_sync_has_changed(mbox, TRUE);
+		if (ret < 0)
+			return -1;
+		if (!want_mail && ret == 0) {
+			/* we're not required to assign UIDs for the appended
+			   mails immediately. do it only if it doesn't require
+			   syncing. */
+			mbox_save_init_sync(t);
 		}
 
 		if (mbox_seek_to_end(ctx, &ctx->append_offset) < 0)
@@ -648,7 +650,7 @@
 		if (fstat(ctx->mbox->mbox_fd, &st) < 0) {
 			mbox_set_syscall_error(ctx->mbox, "fstat()");
 			ret = -1;
-		} else {
+		} else if (!ctx->mbox->mbox_sync_dirty) {
 			uint32_t sync_stamp = st.st_mtime;
 			uint64_t sync_size = st.st_size;