[dovecot-cvs] dovecot/src/lib-index mailbox-list-index-sync.c, 1.3, 1.4

tss at dovecot.org tss at dovecot.org
Fri Jan 19 19:56:56 UTC 2007


Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv24385

Modified Files:
	mailbox-list-index-sync.c 
Log Message:
Fixed index updating when mailboxes were deleted.



Index: mailbox-list-index-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mailbox-list-index-sync.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- mailbox-list-index-sync.c	20 Dec 2006 08:16:41 -0000	1.3
+++ mailbox-list-index-sync.c	19 Jan 2007 19:56:54 -0000	1.4
@@ -640,7 +640,7 @@
 	const struct mailbox_list_dir_record *dir;
 	struct mailbox_list_record *recs;
 	const struct mailbox_list_sync_record *sync_recs;
-	unsigned int i, count;
+	unsigned int i, j, count;
 
 	i_assert(sync_dir->offset != 0);
 
@@ -648,7 +648,7 @@
 		return -1;
 
 	sync_recs = array_get(&sync_dir->records, &count);
-	i_assert(dir->count == count);
+	i_assert(count <= dir->count);
 	i_assert(sync_dir->seen_records_count < count);
 
 	if (!ctx->index->mmap_disable)
@@ -661,9 +661,17 @@
 		memcpy(recs, MAILBOX_LIST_RECORDS(dir),
 		       sizeof(struct mailbox_list_record) * dir->count);
 	}
-	for (i = 0; i < dir->count; i++) {
+
+	/* records marked with deleted have been removed from sync_recs, so
+	   we need to skip those */
+	for (i = j = 0; i < count; i++) {
+		while (recs[j].uid != sync_recs[i].uid) {
+			j++;
+			i_assert(j < dir->count);
+		}
+
 		if (!sync_recs[i].seen)
-			recs[i].deleted = TRUE;
+			recs[j].deleted = TRUE;
 	}
 	if (ctx->index->mmap_disable) {
 		uoff_t offset, old_offset;



More information about the dovecot-cvs mailing list