]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Fix next_uid lookup in open transaction that has appended mails
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 19 Jul 2017 10:43:09 +0000 (13:43 +0300)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Thu, 20 Jul 2017 10:04:21 +0000 (13:04 +0300)
The appended mails were used for returning an updated
mail_index_header.next_uid, but only if the mails were assigned UIDs in
mail_index_append(). It should have updated the next_uid also after
mail_index_append_finish_uids() was used to assign the UIDs.

This fixes setting first_recent_uid correctly for virtual mailboxes when the
sync finds new mails. Avoids multiple sessions from getting \Recent flags
for the same mails.

src/lib-index/mail-index-transaction-update.c

index 56534d1f6bf9adda1d62c76220065614196afe9b..025bb8e9babee337f8368910977ceac9e990c595 100644 (file)
@@ -223,6 +223,8 @@ void mail_index_append_finish_uids(struct mail_index_transaction *t,
                if (recs[i].uid == 0 || recs[i].uid < first_uid) {
                        i_assert(next_uid < (uint32_t)-1);
                        recs[i].uid = next_uid++;
+                       if (t->highest_append_uid < recs[i].uid)
+                               t->highest_append_uid = recs[i].uid;
                } else {
                        if (next_uid != first_uid)
                                t->appends_nonsorted = TRUE;