Mercurial > dovecot > core-2.2
changeset 3340:9c8220dfde7c HEAD
Don't try to handle UIDVALIDITY changes nicely after all. It causes
problems when within same transaction there are two different set of UIDs
being used.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 26 Apr 2005 17:45:46 +0300 |
parents | 5cf828dbcd32 |
children | fa9fd105fae3 |
files | src/lib-storage/index/maildir/maildir-sync.c src/lib-storage/index/mbox/mbox-sync.c |
diffstat | 2 files changed, 12 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-sync.c Tue Apr 26 17:07:31 2005 +0300 +++ b/src/lib-storage/index/maildir/maildir-sync.c Tue Apr 26 17:45:46 2005 +0300 @@ -603,7 +603,6 @@ struct maildir_uidlist_iter_ctx *iter; struct mail_index_transaction *trans; const struct mail_index_header *hdr; - struct mail_index_header tmp_hdr; const struct mail_index_record *rec; pool_t keyword_pool; uint32_t seq, uid; @@ -627,19 +626,8 @@ "Maildir %s sync: UIDVALIDITY changed (%u -> %u)", mbox->path, hdr->uid_validity, uid_validity); - for (seq = 1; seq < hdr->messages_count; seq++) - mail_index_expunge(trans, seq); - - /* Reset uidvalidity and next_uid. */ - memcpy(&tmp_hdr, hdr, sizeof(tmp_hdr)); - tmp_hdr.uid_validity = 0; - tmp_hdr.next_uid = 0; - - /* next_uid must be reset before message syncing begins, - or we get errors about UIDs larger than next_uid. */ - mail_index_update_header(trans, - offsetof(struct mail_index_header, next_uid), - &hdr->next_uid, sizeof(hdr->next_uid), TRUE); + mail_index_mark_corrupted(mbox->ibox.index); + return -1; } keyword_pool = pool_alloconly_create("maildir keywords", 128);
--- a/src/lib-storage/index/mbox/mbox-sync.c Tue Apr 26 17:07:31 2005 +0300 +++ b/src/lib-storage/index/mbox/mbox-sync.c Tue Apr 26 17:45:46 2005 +0300 @@ -927,7 +927,7 @@ const struct mail_index_record *rec; uint32_t uid, messages_count; uoff_t offset; - int ret, expunged, skipped_mails, uidvalidity_changed; + int ret, expunged, skipped_mails; messages_count = mail_index_view_get_messages_count(sync_ctx->sync_view); @@ -942,13 +942,10 @@ while ((ret = mbox_sync_read_next_mail(sync_ctx, mail_ctx)) > 0) { uid = mail_ctx->mail.uid; - uidvalidity_changed = mail_ctx->seq == 1 && - sync_ctx->base_uid_validity != 0 && - sync_ctx->hdr->uid_validity != 0 && - sync_ctx->base_uid_validity != - sync_ctx->hdr->uid_validity; - - if (uidvalidity_changed) { + if (mail_ctx->seq == 1 && sync_ctx->base_uid_validity != 0 && + sync_ctx->hdr->uid_validity != 0 && + sync_ctx->base_uid_validity != + sync_ctx->hdr->uid_validity) { mail_storage_set_critical( STORAGE(sync_ctx->mbox->storage), "UIDVALIDITY changed (%u -> %u) " @@ -957,20 +954,8 @@ sync_ctx->base_uid_validity, sync_ctx->mbox->path); - /* we need to recreate all messages in index */ - while (sync_ctx->idx_seq <= messages_count) { - mail_index_expunge(sync_ctx->t, - sync_ctx->idx_seq++); - } - - /* next_uid must be reset before message syncing - begins, or we get errors about UIDs larger than - next_uid. */ - sync_ctx->idx_next_uid = 0; - mail_index_update_header(sync_ctx->t, - offsetof(struct mail_index_header, next_uid), - &sync_ctx->idx_next_uid, - sizeof(sync_ctx->idx_next_uid), TRUE); + mail_index_mark_corrupted(sync_ctx->mbox->ibox.index); + return -1; } if (mail_ctx->uid_broken && partial) { @@ -983,7 +968,7 @@ uid = 0; rec = NULL; ret = 1; - if (uid != 0 && !uidvalidity_changed) { + if (uid != 0) { ret = mbox_sync_read_index_rec(sync_ctx, uid, &rec); if (ret < 0) return -1; @@ -992,7 +977,7 @@ if (ret == 0) { /* UID found but it's broken */ uid = 0; - } else if (uid == 0 && !uidvalidity_changed && + } else if (uid == 0 && !mail_ctx->pseudo && (sync_ctx->delay_writes || sync_ctx->idx_seq <= messages_count)) { @@ -1015,7 +1000,7 @@ partial = FALSE; } - if (!mail_ctx->pseudo && !uidvalidity_changed) { + if (!mail_ctx->pseudo) { /* get all sync records related to this message */ if (mbox_sync_read_index_syncs(sync_ctx, uid, &expunged) < 0)