summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-08-30 21:02:27 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-08-30 21:02:27 +0900
commitd23d4f3ea20dd12b4819fe6bb5eea1f44e34ea90 (patch)
tree963cf0447fd6eeff46b789f51ce1256e12c9b08c
parent02138181d1153835d77f6ca7b8dbe108c478a3b8 (diff)
downloadbuildstream-tristan/atomic-cache-size-file.tar.gz
_artifactcache/artifactcache.py: Write the cache_size file atomicallytristan/atomic-cache-size-file
This is causing issues while the size file is being read and written simultaneously. The proper fix will be to read/add/save the file atomically and that will require locking, but this fix is a good stop gap to existing crashes.
-rw-r--r--buildstream/_artifactcache/artifactcache.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py
index f28fe394f..f162c7f08 100644
--- a/buildstream/_artifactcache/artifactcache.py
+++ b/buildstream/_artifactcache/artifactcache.py
@@ -571,7 +571,7 @@ class ArtifactCache():
def _write_cache_size(self, size):
assert isinstance(size, int)
size_file_path = os.path.join(self.context.artifactdir, CACHE_SIZE_FILE)
- with open(size_file_path, "w") as f:
+ with utils.save_file_atomic(size_file_path, "w") as f:
f.write(str(size))
# _read_cache_size()