]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Don't allow removing \Recent flags with mail_update_flags()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 18 Jul 2017 09:39:44 +0000 (12:39 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 18 Jul 2017 12:40:08 +0000 (15:40 +0300)
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

src/lib-storage/index/index-mail.c

index 500eb100a0a798b74ae4ccc3da9d241fef503a41..feca8fe98f43c46f91e45d88ff2e1a9d6a80f068 100644 (file)
@@ -2109,19 +2109,6 @@ void index_mail_cache_parse_deinit(struct mail *_mail, time_t received_date,
        (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 @@ void index_mail_update_flags(struct mail *_mail, enum modify_type modify_type,
        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) {