dovecot: If uidlist gets deleted but indexes not, give UIDs to m...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Jul 16 01:23:21 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/3b260c6d9207
changeset: 6027:3b260c6d9207
user: Timo Sirainen <tss at iki.fi>
date: Mon Jul 16 01:21:44 2007 +0300
description:
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.
diffstat:
1 file changed, 25 insertions(+)
src/lib-storage/index/maildir/maildir-sync.c | 25 +++++++++++++++++++++++++
diffs (42 lines):
diff -r 23460b525442 -r 3b260c6d9207 src/lib-storage/index/maildir/maildir-sync.c
--- 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 @@ static int maildir_sync_quick_check(stru
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 @@ static int maildir_sync_context(struct m
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);
}
More information about the dovecot-cvs
mailing list