From: Timo Sirainen Date: Mon, 10 Aug 2020 14:45:08 +0000 (+0300) Subject: lib-index: mail_index_map_latest_sync() - Minor refactoring X-Git-Tag: 2.3.14.rc1~313 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=264f583a4624860ffed0792a5daef85a6c8f7bfd;p=thirdparty%2Fdovecot%2Fcore.git lib-index: mail_index_map_latest_sync() - Minor refactoring --- diff --git a/src/lib-index/mail-index-map-read.c b/src/lib-index/mail-index-map-read.c index 04db3be366..17fa2fdc3c 100644 --- a/src/lib-index/mail-index-map-read.c +++ b/src/lib-index/mail-index-map-read.c @@ -410,23 +410,24 @@ 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); + int ret; + + if (index->log->head == NULL || index->indexid == 0) { + /* we're creating the index file, we don't have any + logs yet */ + return 1; } - 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); - } + + /* and update the map with the latest changes from transaction log */ + ret = mail_index_sync_map(&index->map, type, TRUE, reason); + if (ret != 0) + return ret; + + /* 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; }