]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mail_index_transaction_get_next_uid() shouldn't sort appends. They may still be modified!
authorTimo Sirainen <tss@iki.fi>
Wed, 21 Jan 2009 23:29:44 +0000 (18:29 -0500)
committerTimo Sirainen <tss@iki.fi>
Wed, 21 Jan 2009 23:29:44 +0000 (18:29 -0500)
Fixes a dbox rebuild bug.

--HG--
branch : HEAD

src/lib-index/mail-index-transaction-private.h
src/lib-index/mail-index-transaction.c

index 99bc50589cfb912d8ed6b8f0268fddcceb81d833..7b1e07000e12c20485f5182737f16f729e2af912 100644 (file)
@@ -37,6 +37,7 @@ struct mail_index_transaction {
           mail_index_transaction_reset() to reset it. */
         ARRAY_DEFINE(appends, struct mail_index_record);
        uint32_t first_new_seq, last_new_seq;
+       uint32_t highest_append_uid;
        /* lowest/highest sequence that updates flags/keywords */
        uint32_t min_flagupdate_seq, max_flagupdate_seq;
 
index 20bc88e69b6661f47fd4b1724befc25e945a448d..0a167c4ae18f87f7ea1e80768f2dac900b1943e7 100644 (file)
@@ -537,8 +537,7 @@ void mail_index_transaction_sort_appends(struct mail_index_transaction *t)
 uint32_t mail_index_transaction_get_next_uid(struct mail_index_transaction *t)
 {
        const struct mail_index_header *head_hdr, *hdr;
-       const struct mail_index_record *recs;
-       unsigned int count, offset;
+       unsigned int offset;
        uint32_t next_uid;
 
        head_hdr = &t->view->index->map->hdr;
@@ -547,13 +546,8 @@ uint32_t mail_index_transaction_get_next_uid(struct mail_index_transaction *t)
                1 : hdr->next_uid;
        if (array_is_created(&t->appends)) {
                /* get next_uid from appends if they have UIDs */
-               mail_index_transaction_sort_appends(t);
-
-               recs = array_get(&t->appends, &count);
-               if (count > 0 && recs[count-1].uid != 0) {
-                       i_assert(recs[count-1].uid >= next_uid);
-                       next_uid = recs[count-1].uid + 1;
-               }
+               i_assert(next_uid <= t->highest_append_uid);
+               next_uid = t->highest_append_uid;
        }
 
        /* see if it's been updated in pre/post header changes */
@@ -677,6 +671,8 @@ void mail_index_append(struct mail_index_transaction *t, uint32_t uid,
                        else if (rec->uid == uid)
                                i_panic("Duplicate UIDs added in transaction");
                }
+               if (t->highest_append_uid < uid)
+                       t->highest_append_uid = uid;
        }
 }