Mercurial > dovecot > core-2.2
changeset 12555:b7a8d2a357a8
maildir: Avoid harder to unnecessarily read uidlist when syncing mailbox.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 06 Dec 2010 01:27:03 +0000 |
parents | 8afad3c2928d |
children | c41ba33b8e16 |
files | src/lib-storage/index/maildir/maildir-sync.c |
diffstat | 1 files changed, 17 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-sync.c Mon Dec 06 01:19:25 2010 +0000 +++ b/src/lib-storage/index/maildir/maildir-sync.c Mon Dec 06 01:27:03 2010 +0000 @@ -660,17 +660,21 @@ } } -static bool have_recent_messages(struct maildir_sync_context *ctx) +static bool +have_recent_messages(struct maildir_sync_context *ctx, bool seen_changes) { const struct mail_index_header *hdr; - - (void)maildir_uidlist_refresh(ctx->mbox->uidlist); + uint32_t next_uid; - /* if there are files in new/, we'll need to move them. we'll check - this by checking if we have any recent messages */ hdr = mail_index_get_header(ctx->mbox->box.view); - return hdr->first_recent_uid < - maildir_uidlist_get_next_uid(ctx->mbox->uidlist); + if (!seen_changes) { + /* index is up to date. get the next-uid from it */ + next_uid = hdr->next_uid; + } else { + (void)maildir_uidlist_refresh(ctx->mbox->uidlist); + next_uid = maildir_uidlist_get_next_uid(ctx->mbox->uidlist); + } + return hdr->first_recent_uid < next_uid; } static int maildir_sync_get_changes(struct maildir_sync_context *ctx, @@ -684,15 +688,17 @@ new_changed_r, cur_changed_r) < 0) return -1; + /* if there are files in new/, we'll need to move them. we'll check + this by seeing if we have any recent messages */ if ((mbox->box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0) { if (!*new_changed_r) - *new_changed_r = have_recent_messages(ctx); + *new_changed_r = have_recent_messages(ctx, FALSE); } else if (*new_changed_r) { - /* we have some recent messages and new/ has changed. - if messages had been externally deleted from new/, + /* if recent messages have been externally deleted from new/, we need to get them out of index. this requires that we make sure they weren't just moved to cur/. */ - *cur_changed_r = have_recent_messages(ctx); + if (!*cur_changed_r) + *cur_changed_r = have_recent_messages(ctx, TRUE); } if (*new_changed_r || *cur_changed_r)