From 5742af021ad3ec779a12568e67c83e60127eeef6 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 20 Mar 2021 11:07:09 +0200 Subject: Don't check for file existence in file cache if compression is disabled --- libbuild2/file-cache.cxx | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/libbuild2/file-cache.cxx b/libbuild2/file-cache.cxx index 08fbe77..0c3ef9f 100644 --- a/libbuild2/file-cache.cxx +++ b/libbuild2/file-cache.cxx @@ -37,29 +37,30 @@ namespace build2 { assert (state_ == uninit); - bool c (!comp_path_.empty ()); - // Determine the cache state from the filesystem state. // // First check for the uncompressed file. Its presence means that the // compressed file, if exists, is invalid and we clean it up, similar to // init_new(). // - if (exists (path_)) + // Note that if compression is disabled, we omit the check assuming the + // the uncompressed file exists. + // + if (!comp_path_.empty ()) { - if (c) + if (exists (path_)) + { try_rmfile_ignore_error (comp_path_); - - state_ = uncomp; - } - else if (c && exists (comp_path_)) - { - state_ = comp; + state_ = uncomp; + } + else if (exists (comp_path_)) + { + state_ = comp; + } + else + fail << comp_path_ << " (or its uncompressed variant) does not exist" << + info << "consider cleaning the build state"; } - else - fail << path_ << (c ? " (or its compressed variant)" : "") - << " does not exist" << - info << "consider cleaning the build state"; } void file_cache::entry:: -- cgit v1.1