From ca2f3260811c4ccd0afb774d7e13a5bd64d0cc34 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 24 Nov 2016 15:14:06 +0200 Subject: [PATCH] lib-index: If index open fails with fsck, retry opening once. The fsck should have fixed the log offsets and open should work. --- src/lib-index/mail-index-map-read.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib-index/mail-index-map-read.c b/src/lib-index/mail-index-map-read.c index c21840615e..c9b7f8b31f 100644 --- a/src/lib-index/mail-index-map-read.c +++ b/src/lib-index/mail-index-map-read.c @@ -442,6 +442,14 @@ int mail_index_map(struct mail_index *index, ret = mail_index_sync_map(&index->map, type, TRUE, reason); } + if (ret == 0) { + /* we fsck'd the index. try opening again. */ + ret = mail_index_map_latest_file(index, &reason); + if (ret > 0 && index->indexid != 0) { + ret = mail_index_sync_map(&index->map, + type, TRUE, reason); + } + } } else if (ret == 0 && !index->readonly) { /* make sure we don't try to open the file again */ if (unlink(index->filepath) < 0 && errno != ENOENT) -- 2.47.3