[dovecot-cvs] dovecot/src/lib-index mail-index-transaction.c, 1.46, 1.47

cras at dovecot.org cras at dovecot.org
Sun Jan 23 00:47:54 EET 2005


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

Modified Files:
	mail-index-transaction.c 
Log Message:
fixes



Index: mail-index-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-transaction.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- mail-index-transaction.c	22 Jan 2005 22:34:23 -0000	1.46
+++ mail-index-transaction.c	22 Jan 2005 22:47:51 -0000	1.47
@@ -402,7 +402,7 @@
 {
 	struct mail_transaction_flag_update *updates, tmp_update;
 	size_t size;
-	uint32_t idx;
+	uint32_t idx, move;
 
 	updates = buffer_get_modifyable_data(t->updates, &size);
 	size /= sizeof(*updates);
@@ -432,10 +432,18 @@
 		if (u.uid1 != updates[idx].uid1 &&
 		    (updates[idx].add_flags != u.add_flags ||
 		     updates[idx].remove_flags != u.remove_flags)) {
-			/* split existing update from beginning */
-			tmp_update = updates[idx];
-			tmp_update.uid2 = u.uid1 - 1;
-			updates[idx].uid1 = u.uid1;
+			if (u.uid1 < updates[idx].uid1) {
+				/* insert new update */
+				tmp_update = u;
+				tmp_update.uid2 = updates[idx].uid1 - 1;
+				move = 0;
+			} else {
+				/* split existing update from beginning */
+				tmp_update = updates[idx];
+				tmp_update.uid2 = u.uid1 - 1;
+				updates[idx].uid1 = u.uid1;
+				move = 1;
+			}
 
 			i_assert(tmp_update.uid1 <= tmp_update.uid2);
 			i_assert(updates[idx].uid1 <= updates[idx].uid2);
@@ -443,8 +451,11 @@
 			buffer_insert(t->updates, idx * sizeof(tmp_update),
 				      &tmp_update, sizeof(tmp_update));
 			updates = buffer_get_modifyable_data(t->updates, NULL);
-			size++; idx++;
+			size++; idx += move;
+		} else if (u.uid1 < updates[idx].uid1) {
+			updates[idx].uid1 = u.uid1;
 		}
+
 		if (u.uid2 < updates[idx].uid2 &&
 		    (updates[idx].add_flags != u.add_flags ||
 		     updates[idx].remove_flags != u.remove_flags)) {



More information about the dovecot-cvs mailing list