From: Timo Sirainen Date: Mon, 3 Jul 2023 10:57:25 +0000 (+0300) Subject: mdbox: Replace mdbox_storage_set_corrupted() with mdbox_set_mailbox_corrupted() where... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=83c09378a37340bd9217cfed2f802fbf3e620cee;p=thirdparty%2Fdovecot%2Fcore.git mdbox: Replace mdbox_storage_set_corrupted() with mdbox_set_mailbox_corrupted() where possible --- diff --git a/src/lib-storage/index/dbox-multi/mdbox-mail.c b/src/lib-storage/index/dbox-multi/mdbox-mail.c index ed3fe064fe..1653943f95 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-mail.c +++ b/src/lib-storage/index/dbox-multi/mdbox-mail.c @@ -26,9 +26,8 @@ int mdbox_mail_lookup(struct mdbox_mailbox *mbox, struct mail_index_view *view, dbox_rec = data; if (dbox_rec == NULL || dbox_rec->map_uid == 0) { mail_index_lookup_uid(view, seq, &uid); - mailbox_set_critical(&mbox->box, - "mdbox: map uid lost for uid %u", uid); - mdbox_storage_set_corrupted(mbox->storage); + mdbox_set_mailbox_corrupted(&mbox->box, t_strdup_printf( + "map uid lost for uid %u", uid)); return -1; } @@ -42,10 +41,9 @@ int mdbox_mail_lookup(struct mdbox_mailbox *mbox, struct mail_index_view *view, cur_map_uid_validity = mdbox_map_get_uid_validity(mbox->storage->map); if (cur_map_uid_validity != mbox->map_uid_validity) { - mailbox_set_critical(&mbox->box, - "mdbox: map uidvalidity mismatch (%u vs %u)", - mbox->map_uid_validity, cur_map_uid_validity); - mdbox_storage_set_corrupted(mbox->storage); + mdbox_set_mailbox_corrupted(&mbox->box, t_strdup_printf( + "map uidvalidity mismatch (%u vs %u)", + mbox->map_uid_validity, cur_map_uid_validity)); return -1; } *map_uid_r = dbox_rec->map_uid; diff --git a/src/lib-storage/index/dbox-multi/mdbox-storage.c b/src/lib-storage/index/dbox-multi/mdbox-storage.c index ff332fd494..bf6f336a7f 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-storage.c +++ b/src/lib-storage/index/dbox-multi/mdbox-storage.c @@ -219,10 +219,8 @@ int mdbox_read_header(struct mdbox_mailbox *mbox, &data, &data_size); if (data_size < MDBOX_INDEX_HEADER_MIN_SIZE && (!mbox->creating || data_size != 0)) { - mailbox_set_critical(&mbox->box, - "mdbox: Invalid dbox header size: %zu", - data_size); - mdbox_storage_set_corrupted(mbox->storage); + mdbox_set_mailbox_corrupted(&mbox->box, t_strdup_printf( + "Invalid dbox header size: %zu", data_size)); return -1; } i_zero(hdr); diff --git a/src/lib-storage/index/dbox-multi/mdbox-sync.c b/src/lib-storage/index/dbox-multi/mdbox-sync.c index 8255c910a4..ec1853469d 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-sync.c +++ b/src/lib-storage/index/dbox-multi/mdbox-sync.c @@ -43,10 +43,9 @@ dbox_sync_verify_expunge_guid(struct mdbox_sync_context *ctx, uint32_t seq, memcmp(data, guid_128, GUID_128_SIZE) == 0) return 1; - mailbox_set_critical(&ctx->mbox->box, + mdbox_set_mailbox_corrupted(&ctx->mbox->box, t_strdup_printf( "Expunged GUID mismatch for UID %u: %s vs %s", - uid, guid_128_to_string(data), guid_128_to_string(guid_128)); - mdbox_storage_set_corrupted(ctx->mbox->storage); + uid, guid_128_to_string(data), guid_128_to_string(guid_128))); return -1; } @@ -204,8 +203,10 @@ static int mdbox_sync_try_begin(struct mdbox_sync_context *ctx, ret = index_storage_expunged_sync_begin(&mbox->box, &ctx->index_sync_ctx, &ctx->sync_view, &ctx->trans, sync_flags); - if (mail_index_reset_fscked(mbox->box.index)) - mdbox_storage_set_corrupted(mbox->storage); + if (mail_index_reset_fscked(mbox->box.index)) { + mdbox_set_mailbox_corrupted(&mbox->box, + "dovecot.index was fsck'd (mailbox sync)"); + } if (ret <= 0) return ret; /* error / nothing to do */ @@ -374,7 +375,8 @@ mdbox_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags) int ret = 0; if (mail_index_reset_fscked(box->index)) - mdbox_storage_set_corrupted(mbox->storage); + mdbox_set_mailbox_corrupted(box, "Mailbox index was fsck'd"); + if (index_mailbox_want_full_sync(&mbox->box, flags) || mbox->storage->corrupted_reason != NULL) { if ((flags & MAILBOX_SYNC_FLAG_FORCE_RESYNC) != 0)