[dovecot-cvs] dovecot/src/lib-index/mbox mbox-sync-full.c,1.13,1.14 mbox-sync.c,1.31,1.32

cras at procontrol.fi cras at procontrol.fi
Wed Jul 23 04:29:34 EEST 2003


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

Modified Files:
	mbox-sync-full.c mbox-sync.c 
Log Message:
Mbox syncing / expunging fixes for previous expunge-commit.



Index: mbox-sync-full.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mbox/mbox-sync-full.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- mbox-sync-full.c	21 Jul 2003 14:35:39 -0000	1.13
+++ mbox-sync-full.c	23 Jul 2003 00:29:32 -0000	1.14
@@ -121,7 +121,7 @@
 
 static int match_next_record(struct mail_index *index,
 			     struct mail_index_record *rec,
-			     unsigned int seq, struct istream *input,
+			     unsigned int *seq, struct istream *input,
 			     struct mail_index_record **next_rec, int *dirty)
 {
         struct mail_index_update *update;
@@ -167,7 +167,7 @@
 					     mbox_header_cb, &ctx);
 			md5_final(&ctx.md5, current_digest);
 
-			if (seq == 1) {
+			if (*seq == 1) {
 				if (!mbox_check_uidvalidity(index,
 							    ctx.uid_validity)) {
 					/* uidvalidity changed, abort */
@@ -194,7 +194,7 @@
 
 			/* update flags, unless we've changed them */
 			if ((rec->index_flags & INDEX_MAIL_FLAG_DIRTY) == 0) {
-				if (!index->update_flags(index, rec, seq,
+				if (!index->update_flags(index, rec, *seq,
 							 ctx.flags, TRUE))
 					return FALSE;
 
@@ -231,22 +231,24 @@
 		/* try next message */
 		if (first_rec == NULL) {
 			first_rec = rec;
-			first_seq = seq;
+			first_seq = *seq;
 		}
 		last_rec = rec;
-		last_seq = seq;
+		last_seq = *seq;
 
-		rec = index->next(index, rec); seq++;
+		rec = index->next(index, rec); *seq += 1;
 	} while (rec != NULL);
 
-	if (first_rec == NULL)
+	if (first_rec == NULL) {
+		*seq += 1;
 		*next_rec = rec == NULL ? NULL : index->next(index, rec);
-	else {
+	} else {
 		if (!index->expunge(index, first_rec, last_rec,
 				    first_seq, last_seq, TRUE))
 			return FALSE;
 
-		*next_rec = index->lookup(index, first_seq);
+		*seq = first_seq + 1;
+		*next_rec = index->lookup(index, *seq);
 	}
 
 	return TRUE;
@@ -304,16 +306,13 @@
 		if (input->v_offset == input->v_size)
 			break;
 
-		if (!match_next_record(index, rec, seq, input, &rec, &dirty))
+		if (!match_next_record(index, rec, &seq, input, &rec, &dirty))
 			return FALSE;
 
-		if (rec == NULL) {
+		if (rec == NULL && seq <= index->header->messages_count) {
 			/* Get back to line before From */
 			i_stream_seek(input, from_offset);
-			break;
 		}
-
-		seq++;
 	}
 
 	/* delete the rest of the records */

Index: mbox-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mbox/mbox-sync.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- mbox-sync.c	15 Jun 2003 03:42:28 -0000	1.31
+++ mbox-sync.c	23 Jul 2003 00:29:32 -0000	1.32
@@ -73,8 +73,6 @@
 	uoff_t filesize;
 	int count, fd;
 
-	i_assert(index->lock_type != MAIL_LOCK_SHARED);
-
 	if (index->mailbox_readonly && data_lock_type == MAIL_LOCK_EXCLUSIVE) {
 		index_set_error(index, "sync: %s is read-only, "
 				"can't get exclusive lock",
@@ -89,6 +87,8 @@
 		/* we've already synced in this locking session */
 		return TRUE;
 	}
+
+	i_assert(index->lock_type != MAIL_LOCK_SHARED);
 
 	if (index->fd == -1) {
 		/* anon-mmaped */



More information about the dovecot-cvs mailing list