Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6027:3b260c6d9207 HEAD
If uidlist gets deleted but indexes not, give UIDs to messages beginning
from index's next_uid instead of from 1 and reassigning new UIDs soon.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 16 Jul 2007 01:21:44 +0300 |
parents | 23460b525442 |
children | 68be663e79ec |
files | src/lib-storage/index/maildir/maildir-sync.c |
diffstat | 1 files changed, 25 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-sync.c Mon Jul 16 01:10:13 2007 +0300 +++ b/src/lib-storage/index/maildir/maildir-sync.c Mon Jul 16 01:21:44 2007 +0300 @@ -622,6 +622,29 @@ return 0; } +static void maildir_sync_update_next_uid(struct maildir_mailbox *mbox) +{ + const struct mail_index_header *hdr; + uint32_t uid_validity, next_uid; + + hdr = mail_index_get_header(mbox->ibox.view); + if (hdr->uid_validity == 0) + return; + + uid_validity = maildir_uidlist_get_uid_validity(mbox->uidlist); + next_uid = maildir_uidlist_get_next_uid(mbox->uidlist); + + if (uid_validity == hdr->uid_validity || uid_validity == 0) { + /* make sure uidlist's next_uid is at least as large as + index file's. typically this happens only if uidlist gets + deleted. */ + maildir_uidlist_set_uid_validity(mbox->uidlist, + hdr->uid_validity); + maildir_uidlist_set_next_uid(mbox->uidlist, + hdr->next_uid, FALSE); + } +} + static int maildir_sync_context(struct maildir_sync_context *ctx, bool forced, bool sync_last_commit) { @@ -723,6 +746,8 @@ return -1; } + maildir_sync_update_next_uid(ctx->mbox); + /* finish uidlist syncing, but keep it still locked */ maildir_uidlist_sync_finish(ctx->uidlist_sync_ctx); }