changeset 3341:fa9fd105fae3 HEAD

If we see mbox offsets break, don't invalidate whole index but rather force resyncing.
author Timo Sirainen <tss@iki.fi>
date Tue, 26 Apr 2005 17:52:02 +0300
parents 9c8220dfde7c
children 43d4aad84752
files src/lib-storage/index/mbox/mbox-file.c src/lib-storage/index/mbox/mbox-mail.c src/lib-storage/index/mbox/mbox-sync-private.h src/lib-storage/index/mbox/mbox-sync.c
diffstat 4 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/mbox-file.c	Tue Apr 26 17:45:46 2005 +0300
+++ b/src/lib-storage/index/mbox/mbox-file.c	Tue Apr 26 17:52:02 2005 +0300
@@ -137,8 +137,7 @@
 		mail_storage_set_critical(STORAGE(mbox->storage),
 			"Cached message offset lost for seq %u in mbox file %s",
 			seq, mbox->path);
-		mail_index_mark_corrupted(mbox->ibox.index);
-		return -1;
+		return 0;
 	}
 
 	offset = *((const uint64_t *)data);
@@ -155,8 +154,7 @@
 		mail_storage_set_critical(STORAGE(mbox->storage),
 			"Cached message offset %s is invalid for mbox file %s",
 			dec2str(offset), mbox->path);
-		mail_index_mark_corrupted(mbox->ibox.index);
-		return -1;
+		return 0;
 	}
 
 	if (mbox->mbox_sync_dirty) {
--- a/src/lib-storage/index/mbox/mbox-mail.c	Tue Apr 26 17:45:46 2005 +0300
+++ b/src/lib-storage/index/mbox/mbox-mail.c	Tue Apr 26 17:52:02 2005 +0300
@@ -65,7 +65,7 @@
 			i_assert(mbox->mbox_lock_type == F_UNLCK);
 		}
 
-		sync_flags |= MBOX_SYNC_UNDIRTY;
+		sync_flags |= MBOX_SYNC_UNDIRTY | MBOX_SYNC_FORCE_SYNC;
 		goto __again;
 	}
 
--- a/src/lib-storage/index/mbox/mbox-sync-private.h	Tue Apr 26 17:45:46 2005 +0300
+++ b/src/lib-storage/index/mbox/mbox-sync-private.h	Tue Apr 26 17:52:02 2005 +0300
@@ -9,7 +9,8 @@
 	MBOX_SYNC_HEADER	= 0x02,
 	MBOX_SYNC_LOCK_READING	= 0x04,
 	MBOX_SYNC_UNDIRTY	= 0x08,
-	MBOX_SYNC_REWRITE	= 0x10
+	MBOX_SYNC_REWRITE	= 0x10,
+	MBOX_SYNC_FORCE_SYNC	= 0x20
 };
 
 struct mbox_flag_type {
--- a/src/lib-storage/index/mbox/mbox-sync.c	Tue Apr 26 17:45:46 2005 +0300
+++ b/src/lib-storage/index/mbox/mbox-sync.c	Tue Apr 26 17:52:02 2005 +0300
@@ -1329,8 +1329,12 @@
 		return -1;
 	}
 
-	if ((uint32_t)st->st_mtime == sync_ctx->hdr->sync_stamp &&
-	    (uint64_t)st->st_size == sync_ctx->hdr->sync_size) {
+	if ((flags & MBOX_SYNC_FORCE_SYNC) != 0) {
+		/* forcing a full sync. assume file has changed. */
+		partial = FALSE;
+		sync_ctx->mbox->mbox_sync_dirty = TRUE;
+	} else if ((uint32_t)st->st_mtime == sync_ctx->hdr->sync_stamp &&
+		   (uint64_t)st->st_size == sync_ctx->hdr->sync_size) {
 		/* file is fully synced */
 		partial = TRUE;
 		sync_ctx->mbox->mbox_sync_dirty = FALSE;
@@ -1443,7 +1447,8 @@
 			return -1;
 	}
 
-	if ((flags & MBOX_SYNC_HEADER) != 0)
+	if ((flags & MBOX_SYNC_HEADER) != 0 ||
+	    (flags & MBOX_SYNC_FORCE_SYNC) != 0)
 		changed = 1;
 	else {
 		int leave_dirty = (flags & MBOX_SYNC_UNDIRTY) == 0;