From fded15721a2690c2427377d72dbaccadbd4f78fa Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Fri, 3 Apr 2020 00:22:45 +0300 Subject: [PATCH] lib-index: Add mail_cache_record_corrupted event --- src/lib-index/mail-cache.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lib-index/mail-cache.c b/src/lib-index/mail-cache.c index 4de6aea9dd..c7197cd4b8 100644 --- a/src/lib-index/mail-cache.c +++ b/src/lib-index/mail-cache.c @@ -58,14 +58,10 @@ void mail_cache_set_corrupted(struct mail_cache *cache, const char *fmt, ...) void mail_cache_set_seq_corrupted_reason(struct mail_cache_view *cache_view, uint32_t seq, const char *reason) { - uint32_t empty = 0; + uint32_t uid, empty = 0; struct mail_cache *cache = cache_view->cache; struct mail_index_view *view = cache_view->view; - mail_index_set_error(cache->index, - "Corrupted record in index cache file %s: %s", - cache->filepath, reason); - /* drop cache pointer */ struct mail_index_transaction *t = mail_index_transaction_begin(view, MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL); @@ -76,6 +72,14 @@ void mail_cache_set_seq_corrupted_reason(struct mail_cache_view *cache_view, maybe it works again later. */ return; } + + mail_index_lookup_uid(cache_view->view, seq, &uid); + const char *errstr = t_strdup_printf( + "Deleting corrupted cache record uid=%u: %s", uid, reason); + e_error(event_create_passthrough(cache->event)-> + set_name("mail_cache_record_corrupted")-> + add_int("uid", uid)-> + add_str("reason", reason)->event(), "%s", errstr); mail_cache_expunge_count(cache, 1); } -- 2.47.3