aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-03-20 11:07:09 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-03-20 11:07:09 +0200
commit5742af021ad3ec779a12568e67c83e60127eeef6 (patch)
treeb150c89dffb2c12cf28fba904b6e68579d72817e
parentc3635a23429f871c9384ba83f327779f73bebcd7 (diff)
Don't check for file existence in file cache if compression is disabled
-rw-r--r--libbuild2/file-cache.cxx29
1 files 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::