]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Add mail_cache_record_corrupted event
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 2 Apr 2020 21:22:45 +0000 (00:22 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 15 Apr 2020 09:41:43 +0000 (12:41 +0300)
src/lib-index/mail-cache.c

index 4de6aea9dd72eba15c07641075c929bde9ea4fb6..c7197cd4b8550b0725bc2b17db1611018acd8d99 100644 (file)
@@ -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);
 }