changeset 1800:9f25c3d7b378 HEAD

mbox rewriting should work again..
author Timo Sirainen <tss@iki.fi>
date Sun, 05 Oct 2003 20:23:38 +0300
parents eaf7de575156
children fe13672d14b3
files src/lib-index/mbox/mbox-rewrite.c src/lib-index/mbox/mbox-sync-full.c
diffstat 2 files changed, 15 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mbox/mbox-rewrite.c	Fri Oct 03 19:20:58 2003 +0300
+++ b/src/lib-index/mbox/mbox-rewrite.c	Sun Oct 05 20:23:38 2003 +0300
@@ -48,7 +48,9 @@
 	while (rec != NULL) {
 		index_flags = mail_cache_get_index_flags(index->cache, rec);
 		if ((index_flags & MAIL_INDEX_FLAG_DIRTY) != 0) {
-			if (!mail_cache_update_index_flags(index->cache, rec, index_flags))
+			index_flags &= ~MAIL_INDEX_FLAG_DIRTY;
+			if (!mail_cache_update_index_flags(index->cache,
+							   rec, index_flags))
 				return FALSE;
 		}
 
@@ -76,7 +78,7 @@
 				strerror(output->stream_errno));
 		failed = TRUE;
 	} else if (input->v_offset < end_offset) {
-		/* fsck should have noticed it.. */
+		/* sync should have noticed it.. */
 		index_set_error(index, "Error rewriting mbox file %s: "
 				"Unexpected end of file", index->mailbox_path);
 		failed = TRUE;
@@ -382,7 +384,6 @@
 static int mbox_write_header(struct mail_index *index,
 			     struct mail_index_record *rec, unsigned int seq,
 			     struct istream *input, struct ostream *output,
-			     uoff_t end_offset,
 			     uoff_t *hdr_input_size, uoff_t body_size)
 {
 	/* We need to update fields that define message flags. Standard fields
@@ -403,13 +404,6 @@
 	uoff_t offset;
 	int force_filler;
 
-	if (input->v_offset >= end_offset) {
-		/* fsck should have noticed it.. */
-		index_set_error(index, "Error rewriting mbox file %s: "
-				"Unexpected end of file", index->mailbox_path);
-		return FALSE;
-	}
-
 	t_push();
 
 	/* parse the header, write the fields we don't want to change */
@@ -712,7 +706,7 @@
 
 			/* write header, updating flag fields */
 			if (!mbox_write_header(index, rec, seq, input, output,
-					       offset, &hdr_size, body_size)) {
+					       &hdr_size, body_size)) {
 				failed = TRUE;
 				break;
 			}
--- a/src/lib-index/mbox/mbox-sync-full.c	Fri Oct 03 19:20:58 2003 +0300
+++ b/src/lib-index/mbox/mbox-sync-full.c	Sun Oct 05 20:23:38 2003 +0300
@@ -150,9 +150,13 @@
 							 MODIFY_REPLACE,
 							 ctx.flags, TRUE))
 					return FALSE;
+			} else if (rec->msg_flags == ctx.flags) {
+				/* flags are same, it's not dirty anymore */
+				index_flags &= ~MAIL_INDEX_FLAG_DIRTY;
+				mail_cache_update_index_flags(index->cache,
+							      rec, index_flags);
 			} else {
-				if (rec->msg_flags != ctx.flags)
-					*dirty = TRUE;
+				*dirty = TRUE;
 			}
 
 			/* update location */
@@ -200,6 +204,10 @@
 	unsigned int seq;
 	int dirty;
 
+	if (mail_cache_lock(index->cache, FALSE) <= 0)
+		return FALSE;
+	mail_cache_unlock_later(index->cache);
+
 	mbox_skip_empty_lines(input);
 
 	/* first make sure we start with a "From " line. If file is too