[dovecot-cvs] dovecot/src/lib-storage/index/dbox dbox-uidlist.c, 1.26, 1.27

cras at dovecot.org cras at dovecot.org
Thu Apr 27 15:44:21 EEST 2006


Update of /var/lib/cvs/dovecot/src/lib-storage/index/dbox
In directory talvi:/tmp/cvs-serv19035

Modified Files:
	dbox-uidlist.c 
Log Message:
Fixes



Index: dbox-uidlist.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-uidlist.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- dbox-uidlist.c	27 Apr 2006 12:33:21 -0000	1.26
+++ dbox-uidlist.c	27 Apr 2006 12:44:19 -0000	1.27
@@ -165,6 +165,17 @@
 	return (int)*file_seq - (int)(*entry)->file_seq;
 }
 
+static void dbox_uidlist_update_last_uid(struct dbox_uidlist *uidlist,
+					 const struct dbox_uidlist_entry *entry)
+{
+	const struct seq_range *range;
+	unsigned int count;
+
+	range = array_get(&entry->uid_list, &count);
+	if (range[count-1].seq2 > uidlist->last_uid)
+		uidlist->last_uid = range[count-1].seq2;
+}
+
 static bool dbox_uidlist_add_entry(struct dbox_uidlist *uidlist,
 				   const struct dbox_uidlist_entry *src_entry)
 {
@@ -172,6 +183,8 @@
 	const struct seq_range *range;
 	unsigned int i, idx, count;
 
+	dbox_uidlist_update_last_uid(uidlist, src_entry);
+
 	entries = array_get_modifyable(&uidlist->entries, &count);
 	if (count == 0 || src_entry->file_seq > entries[count-1]->file_seq) {
 		/* append new file sequence */
@@ -546,6 +559,7 @@
 
 	entries = array_get(&uidlist->entries, &count);
 	for (i = 0; i < count; i++) {
+		i_assert(entries[i]->file_seq <= uidlist->last_file_seq);
 		str_truncate(str, 0);
 
 		i_assert(i == 0 ||
@@ -555,6 +569,7 @@
 		range = array_get(&entries[i]->uid_list, &range_count);
 		i_assert(range_count != 0);
 		for (ui = 0; ui < range_count; ui++) {
+			i_assert(range[ui].seq2 <= uidlist->last_uid);
 			if (str_len(str) > 0)
 				str_append_c(str, ',');
 			if (range[ui].seq1 == range[ui].seq2)
@@ -1253,6 +1268,10 @@
 		     struct seq_range, array_count(&entry->uid_list) + 1);
 	array_append_array(&new_entry->uid_list, &entry->uid_list);
 
+	if (new_entry->file_seq > ctx->uidlist->last_file_seq)
+		ctx->uidlist->last_file_seq = new_entry->file_seq;
+	dbox_uidlist_update_last_uid(ctx->uidlist, new_entry);
+
 	entries = array_get(&ctx->uidlist->entries, &count);
 	if (count == 0 || entries[count-1]->file_seq < new_entry->file_seq)
 		array_append(&ctx->uidlist->entries, &new_entry, 1);



More information about the dovecot-cvs mailing list