changeset 22360:d5c4dca315de

lib-storage: Don't allow removing \Recent flags with mail_update_flags() Reverts an ancient commit 7deb24e7453249d09741641bff0f269f68165033. I don't know why it was added in the first place. Normally \Recent flags are removed during sync with MAIL_INDEX_SYNC_FLAG_DROP_RECENT. This should be enough, especially since it's not even possible to remove a single \Recent flag - only update the first_recent_uid. The code was also wrong: It was dropping \Recent flags even when modify_type/flags combination didn't ask for it. Even if this was fixed, there would still be race conditions with multiple processes since this update is done without locking. Fixes: Error: Recent flags state corrupted for mailbox
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Tue, 18 Jul 2017 12:39:44 +0300
parents 04910d5ceb05
children 73479718bc0b
files src/lib-storage/index/index-mail.c
diffstat 1 files changed, 0 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/index-mail.c	Tue Jul 18 11:57:24 2017 +0300
+++ b/src/lib-storage/index/index-mail.c	Tue Jul 18 12:39:44 2017 +0300
@@ -2109,19 +2109,6 @@
 	(void)index_mail_parse_body_finish(mail, 0, success);
 }
 
-static void index_mail_drop_recent_flag(struct mail *mail)
-{
-	const struct mail_index_header *hdr;
-	uint32_t first_recent_uid = mail->uid + 1;
-
-	hdr = mail_index_get_header(mail->transaction->view);
-	if (hdr->first_recent_uid < first_recent_uid) {
-		mail_index_update_header(mail->transaction->itrans,
-			offsetof(struct mail_index_header, first_recent_uid),
-			&first_recent_uid, sizeof(first_recent_uid), FALSE);
-	}
-}
-
 static bool
 index_mail_update_pvt_flags(struct mail *_mail, enum modify_type modify_type,
 			    enum mail_flags pvt_flags)
@@ -2157,9 +2144,6 @@
 	enum mail_flags pvt_flags_mask, pvt_flags = 0;
 	bool update_modseq = FALSE;
 
-	if ((flags & MAIL_RECENT) == 0 &&
-	    mailbox_recent_flags_have_uid(_mail->box, _mail->uid))
-		index_mail_drop_recent_flag(_mail);
 	flags &= MAIL_FLAGS_NONRECENT | MAIL_INDEX_MAIL_FLAG_BACKEND;
 
 	if (_mail->box->view_pvt != NULL) {