# HG changeset patch # User Timo Sirainen # Date 1489682788 -7200 # Node ID 5a5e046c42ec3f1e38201ef8d5fa777a4f8061a3 # Parent 4a203e1b63897c76cee71e728e9da9607992ba73 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 -r 4a203e1b6389 -r 5a5e046c42ec src/lib-storage/index/index-rebuild.c --- a/src/lib-storage/index/index-rebuild.c Thu Mar 16 09:38:59 2017 +0200 +++ b/src/lib-storage/index/index-rebuild.c Thu Mar 16 18:46:28 2017 +0200 @@ -98,7 +98,7 @@ 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); @@ -131,6 +131,17 @@ &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);