aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/file-cache.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-03-18 15:02:39 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-03-18 15:02:39 +0200
commit6b9bdad3b68b12ff8e2075d54c1f7f005bb2f768 (patch)
tree8ccd47c832ea6fd8dea6d12e3b9f36c8c0e72033 /libbuild2/file-cache.cxx
parent562af3a7f3742bf57b007e904e0bb661a5da1dab (diff)
Add noop mode to file cache, add --file-cache option to select
Diffstat (limited to 'libbuild2/file-cache.cxx')
-rw-r--r--libbuild2/file-cache.cxx16
1 files changed, 11 insertions, 5 deletions
diff --git a/libbuild2/file-cache.cxx b/libbuild2/file-cache.cxx
index 107bf3f..0c2fcbb 100644
--- a/libbuild2/file-cache.cxx
+++ b/libbuild2/file-cache.cxx
@@ -26,7 +26,8 @@ namespace build2
// to compressing the new file (for example, if we fail and leave the
// uncompressed file behind for troubleshooting).
//
- try_rmfile_ignore_error (comp_path_);
+ if (!comp_path_.empty ())
+ try_rmfile_ignore_error (comp_path_);
pin ();
return write (*this);
@@ -37,6 +38,8 @@ 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
@@ -45,15 +48,18 @@ namespace build2
//
if (exists (path_))
{
- try_rmfile_ignore_error (comp_path_);
+ if (c)
+ try_rmfile_ignore_error (comp_path_);
+
state_ = uncomp;
}
- else if (exists (comp_path_))
+ else if (c && exists (comp_path_))
{
state_ = comp;
}
else
- fail << path_ << " (or its compressed variant) does not exist" <<
+ fail << path_ << (c ? " (or its compressed variant)" : "")
+ << " does not exist" <<
info << "consider cleaning the build state";
}
@@ -158,7 +164,7 @@ namespace build2
// file, then we don't attempt to remove the uncompressed file either
// since it could be an indicator that the compressed file is invalid.
//
- if (try_rmfile_ignore_error (comp_path_))
+ if (comp_path_.empty () || try_rmfile_ignore_error (comp_path_))
try_rmfile_ignore_error (path_);
break;
}