Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6041:f2ab0b7e5ae6 HEAD
If a message was expunged that wasn't yet even visible to our view, it might
have still been in recent flags array. Make sure it gets removed from there.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 17 Jul 2007 21:19:14 +0300 |
parents | fef4aad133dd |
children | 99aace97fb4e |
files | src/lib-storage/index/index-sync.c |
diffstat | 1 files changed, 34 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/index-sync.c Tue Jul 17 21:16:23 2007 +0300 +++ b/src/lib-storage/index/index-sync.c Tue Jul 17 21:19:14 2007 +0300 @@ -258,6 +258,38 @@ return 0; } +static int index_mailbox_expunge_unseen_recent(struct index_mailbox *ibox) +{ + const struct mail_index_header *hdr; + uint32_t uid; + + if (!array_is_created(&ibox->recent_flags)) + return 0; + + /* expunges array contained expunges for the messages that were already + visible in this view, but append+expunge would be invisible. + recent_flags may however contain the append UID, so we'll have to + remove it separately */ + hdr = mail_index_get_header(ibox->view); + if (hdr->messages_count == 0) + uid = 0; + else { + if (mail_index_lookup_uid(ibox->view, hdr->messages_count, + &uid) < 0) { + mail_storage_set_index_error(ibox); + return -1; + } + } + + if (uid + 1 < hdr->next_uid) { + ibox->recent_flags_count -= + seq_range_array_remove_range(&ibox->recent_flags, + uid + 1, + hdr->next_uid - 1); + } + return 0; +} + int index_mailbox_sync_deinit(struct mailbox_sync_context *_ctx, enum mailbox_status_items status_items, struct mailbox_status *status_r) @@ -271,6 +303,8 @@ if (ctx->sync_ctx != NULL) mail_index_view_sync_end(&ctx->sync_ctx); + if (index_mailbox_expunge_unseen_recent(ibox) < 0) + ret = -1; if (ibox->keep_recent) { /* mailbox syncing didn't necessarily update our recent state */