Mercurial > dovecot > core-2.2
changeset 21763:5a5e046c42ec
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.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Thu, 16 Mar 2017 18:46:28 +0200 |
parents | 4a203e1b6389 |
children | 04edf83cff79 |
files | src/lib-storage/index/index-rebuild.c |
diffstat | 1 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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);