changeset 22374:542b9643d6b1

lib-index: Fix next_uid lookup in open transaction that has appended mails 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.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Wed, 19 Jul 2017 13:43:09 +0300
parents bc9c3065ec23
children 06def4e9a4a2
files src/lib-index/mail-index-transaction-update.c
diffstat 1 files changed, 2 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-transaction-update.c	Thu Jul 20 09:46:00 2017 +0300
+++ b/src/lib-index/mail-index-transaction-update.c	Wed Jul 19 13:43:09 2017 +0300
@@ -223,6 +223,8 @@
 		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;