[dovecot-cvs] dovecot/src/lib-index/mbox mbox-rewrite.c,1.63,1.64 mbox-sync-full.c,1.16,1.17

cras at procontrol.fi cras at procontrol.fi
Sun Oct 5 21:23:40 EEST 2003


Update of /home/cvs/dovecot/src/lib-index/mbox
In directory danu:/tmp/cvs-serv11528/lib-index/mbox

Modified Files:
	mbox-rewrite.c mbox-sync-full.c 
Log Message:
mbox rewriting should work again..



Index: mbox-rewrite.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mbox/mbox-rewrite.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- mbox-rewrite.c	29 Sep 2003 14:15:06 -0000	1.63
+++ mbox-rewrite.c	5 Oct 2003 17:23:38 -0000	1.64
@@ -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;
 			}

Index: mbox-sync-full.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mbox/mbox-sync-full.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- mbox-sync-full.c	2 Sep 2003 22:33:33 -0000	1.16
+++ mbox-sync-full.c	5 Oct 2003 17:23:38 -0000	1.17
@@ -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 */
@@ -199,6 +203,10 @@
 	size_t size;
 	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);
 



More information about the dovecot-cvs mailing list