From: Timo Sirainen Date: Thu, 16 Mar 2017 16:46:28 +0000 (+0200) Subject: lib-storage: Don't reset \Recent flags when rebuilding index X-Git-Tag: 2.3.0.rc1~1930 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5eb43c3bb43c559cc54d66504c7b79183d45e803;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Don't reset \Recent flags when rebuilding index The recent flags are tracked with first_recent_uid in the header. If the first_recent_uid is valid in the old index, preserve it. This way all mails don't show as having \Recent flag. This was used by sdbox and mdbox code. --- diff --git a/src/lib-storage/index/index-rebuild.c b/src/lib-storage/index/index-rebuild.c index f5cf154a20..6533f061d7 100644 --- a/src/lib-storage/index/index-rebuild.c +++ b/src/lib-storage/index/index-rebuild.c @@ -99,7 +99,7 @@ index_rebuild_header(struct index_rebuild_context *ctx, struct mail_index *index = mail_index_view_get_index(ctx->view); struct mail_index_modseq_header modseq_hdr; struct mail_index_view *trans_view; - uint32_t uid_validity, next_uid; + uint32_t uid_validity, next_uid, first_recent_uid; uint64_t modseq; hdr = mail_index_get_header(ctx->view); @@ -132,6 +132,17 @@ index_rebuild_header(struct index_rebuild_context *ctx, &next_uid, sizeof(next_uid), FALSE); } + /* set first_recent_uid */ + first_recent_uid = hdr->first_recent_uid; + if (backup_hdr != NULL && + backup_hdr->first_recent_uid > first_recent_uid && + backup_hdr->first_recent_uid <= next_uid) + first_recent_uid = backup_hdr->first_recent_uid; + first_recent_uid = I_MIN(first_recent_uid, next_uid); + mail_index_update_header(ctx->trans, + offsetof(struct mail_index_header, first_recent_uid), + &first_recent_uid, sizeof(first_recent_uid), FALSE); + /* set highest-modseq */ i_zero(&modseq_hdr); modseq_hdr.highest_modseq = mail_index_modseq_get_highest(ctx->view);