From 9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 23 Jun 2004 06:31:52 +0300 Subject: [PATCH] Complain about reappearing UIDs, but reassign new UIDs to them anyway. Don't try to update \recent mails if we aren't really going to make them non-recent. --HG-- branch : HEAD --- src/lib-storage/index/mbox/mbox-sync.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/lib-storage/index/mbox/mbox-sync.c b/src/lib-storage/index/mbox/mbox-sync.c index 101e5c0b82..ba72ccdfeb 100644 --- a/src/lib-storage/index/mbox/mbox-sync.c +++ b/src/lib-storage/index/mbox/mbox-sync.c @@ -223,8 +223,10 @@ mbox_sync_read_next_mail(struct mbox_sync_context *sync_ctx, /* save the offset permanently with recent flag state */ mail_ctx->mail.from_offset = mail_ctx->from_offset; if ((mail_ctx->mail.flags & MBOX_NONRECENT) == 0) { - /* need to add 'O' flag to Status-header */ - mail_ctx->need_rewrite = TRUE; + if (!sync_ctx->ibox->keep_recent) { + /* need to add 'O' flag to Status-header */ + mail_ctx->need_rewrite = TRUE; + } // FIXME: save it somewhere } return 1; @@ -340,13 +342,21 @@ mbox_sync_read_index_rec(struct mbox_sync_context *sync_ctx, rec = NULL; } - if (rec != NULL && rec->uid != uid) { + if (ret == 0 && uid < sync_ctx->hdr->next_uid) { + /* this UID was already in index and it was expunged */ + mail_storage_set_critical(sync_ctx->ibox->box.storage, + "mbox sync: Expunged message reappeared in mailbox %s " + "(UID %u < %u)", sync_ctx->ibox->path, uid, + sync_ctx->hdr->next_uid); + ret = 0; + } else if (rec != NULL && rec->uid != uid) { /* new UID in the middle of the mailbox - shouldn't happen */ mail_storage_set_critical(sync_ctx->ibox->box.storage, "mbox sync: UID inserted in the middle of mailbox %s " "(%u > %u)", sync_ctx->ibox->path, rec->uid, uid); - mail_index_mark_corrupted(sync_ctx->ibox->index); - return -1; + ret = 0; + } else { + ret = 1; } *rec_r = rec; @@ -747,12 +757,8 @@ static int mbox_sync_loop(struct mbox_sync_context *sync_ctx, ret = mbox_sync_read_index_rec(sync_ctx, uid, &rec); if (ret < 0) return -1; - if (ret == 0 && uid < sync_ctx->hdr->next_uid) { - /* this UID was already in index and it was - expunged */ + if (ret == 0) uid = 0; - rec = NULL; - } } if (uid == 0) { /* missing/broken X-UID. all the rest of the mails -- 2.47.3