Mercurial > dovecot > core-2.2
changeset 13209:1fb6cc545575
lib-storage: Fixed getting recent count for mailbox when it wasn't synced.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 10 Aug 2011 16:16:57 +0300 |
parents | e6eaf803ce09 |
children | f7b10bfa6bbf |
files | src/lib-storage/index/index-status.c src/lib-storage/index/index-storage.h src/lib-storage/index/index-sync.c |
diffstat | 3 files changed, 24 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/index-status.c Wed Aug 10 16:08:45 2011 +0300 +++ b/src/lib-storage/index/index-status.c Wed Aug 10 16:16:57 2011 +0300 @@ -26,6 +26,9 @@ hdr = mail_index_get_header(box->view); status_r->messages = hdr->messages_count; if ((items & STATUS_RECENT) != 0) { + /* make sure recent count is set, in case syncing hasn't + been done yet */ + index_sync_update_recent_count(box); status_r->recent = index_mailbox_get_recent_count(box); i_assert(status_r->recent <= status_r->messages); }
--- a/src/lib-storage/index/index-storage.h Wed Aug 10 16:08:45 2011 +0300 +++ b/src/lib-storage/index/index-storage.h Wed Aug 10 16:16:57 2011 +0300 @@ -103,6 +103,7 @@ int index_storage_sync(struct mailbox *box, enum mailbox_sync_flags flags); enum mailbox_sync_type index_sync_type_convert(enum mail_index_sync_type type); +void index_sync_update_recent_count(struct mailbox *box); int index_storage_get_status(struct mailbox *box, enum mailbox_status_items items, struct mailbox_status *status_r);
--- a/src/lib-storage/index/index-sync.c Wed Aug 10 16:08:45 2011 +0300 +++ b/src/lib-storage/index/index-sync.c Wed Aug 10 16:16:57 2011 +0300 @@ -463,15 +463,31 @@ return cache_add(box, cache); } +void index_sync_update_recent_count(struct mailbox *box) +{ + struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box); + const struct mail_index_header *hdr; + uint32_t seq1, seq2; + + hdr = mail_index_get_header(box->view); + if (hdr->first_recent_uid > ibox->recent_flags_prev_uid) { + mail_index_lookup_seq_range(box->view, + hdr->first_recent_uid, + hdr->next_uid, + &seq1, &seq2); + if (seq1 != 0) { + index_mailbox_set_recent_seq(box, box->view, + seq1, seq2); + } + } +} + int index_mailbox_sync_deinit(struct mailbox_sync_context *_ctx, struct mailbox_sync_status *status_r) { struct index_mailbox_sync_context *ctx = (struct index_mailbox_sync_context *)_ctx; - struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(_ctx->box); struct mailbox_sync_rec sync_rec; - const struct mail_index_header *hdr; - uint32_t seq1, seq2; bool delayed_expunges = FALSE; int ret = ctx->failed ? -1 : 0; @@ -494,18 +510,7 @@ if ((_ctx->box->flags & MAILBOX_FLAG_KEEP_RECENT) != 0 && _ctx->box->opened) { /* mailbox syncing didn't necessarily update our recent state */ - hdr = mail_index_get_header(_ctx->box->view); - if (hdr->first_recent_uid > ibox->recent_flags_prev_uid) { - mail_index_lookup_seq_range(_ctx->box->view, - hdr->first_recent_uid, - hdr->next_uid, - &seq1, &seq2); - if (seq1 != 0) { - index_mailbox_set_recent_seq(_ctx->box, - _ctx->box->view, - seq1, seq2); - } - } + index_sync_update_recent_count(_ctx->box); } if (status_r != NULL)