From: Timo Sirainen Date: Thu, 1 Apr 2021 14:24:10 +0000 (+0300) Subject: lib-index: Try harder to open index with MAIL_INDEX_OPEN_FLAG_READONLY X-Git-Tag: 2.3.16~209 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c9fa2001758e7b1892092f1e387d6ccca62d036e;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Try harder to open index with MAIL_INDEX_OPEN_FLAG_READONLY The readonly-flag is used when rebuilding index or dumping indexes. In both cases it's better to try to open the index as best as possible, since fsck isn't allowed. --- diff --git a/src/lib-index/mail-index-map-read.c b/src/lib-index/mail-index-map-read.c index 12500f393d..9a8b3341c7 100644 --- a/src/lib-index/mail-index-map-read.c +++ b/src/lib-index/mail-index-map-read.c @@ -445,8 +445,10 @@ mail_index_map_latest_sync(struct mail_index *index, "(reopen_reason: %s)", index->filepath, reason, map_reason, reopen_reason); - if (mail_index_fsck(index) < 0) - return -1; + if (!index->readonly) { + if (mail_index_fsck(index) < 0) + return -1; + } } ret = mail_index_map_latest_file(index, &reason); diff --git a/src/lib-index/mail-index.c b/src/lib-index/mail-index.c index 809547ed49..9796c394be 100644 --- a/src/lib-index/mail-index.c +++ b/src/lib-index/mail-index.c @@ -507,7 +507,7 @@ mail_index_try_open(struct mail_index *index) return 0; ret = mail_index_map(index, MAIL_INDEX_SYNC_HANDLER_HEAD); - if (ret == 0) { + if (ret == 0 && !index->readonly) { /* it's corrupted - recreate it */ if (index->fd != -1) { if (close(index->fd) < 0) @@ -596,7 +596,7 @@ static int mail_index_open_files(struct mail_index *index, } if (ret >= 0) { ret = index->map != NULL ? 1 : mail_index_try_open(index); - if (ret == 0) { + if (ret == 0 && !index->readonly) { /* corrupted */ mail_transaction_log_close(index->log); ret = mail_transaction_log_create(index->log, TRUE);