From: Timo Sirainen Date: Mon, 10 Aug 2020 14:43:50 +0000 (+0300) Subject: lib-index: Split off mail_index_map_latest_sync() X-Git-Tag: 2.3.14.rc1~314 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dd5ee8e233d79f22c7bd7a313ff6973096cb1940;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Split off mail_index_map_latest_sync() --- diff --git a/src/lib-index/mail-index-map-read.c b/src/lib-index/mail-index-map-read.c index e05305e6ea..04db3be366 100644 --- a/src/lib-index/mail-index-map-read.c +++ b/src/lib-index/mail-index-map-read.c @@ -405,6 +405,32 @@ mail_index_map_latest_file(struct mail_index *index, const char **reason_r) return 1; } +static int +mail_index_map_latest_sync(struct mail_index *index, + enum mail_index_sync_handler_type type, + const char *reason) +{ + int ret = 1; + + /* if we're creating the index file, we don't have any + logs yet */ + if (index->log->head != NULL && index->indexid != 0) { + /* and update the map with the latest changes + from transaction log */ + 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); + } + } + return ret; +} + int mail_index_map(struct mail_index *index, enum mail_index_sync_handler_type type) { @@ -439,22 +465,7 @@ int mail_index_map(struct mail_index *index, don't even try to use the transaction log. */ ret = mail_index_map_latest_file(index, &reason); if (ret > 0) { - /* if we're creating the index file, we don't have any - logs yet */ - if (index->log->head != NULL && index->indexid != 0) { - /* and update the map with the latest changes - from transaction log */ - 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); - } - } + ret = mail_index_map_latest_sync(index, type, 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)