diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-08-30 21:02:27 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-08-30 21:10:40 +0900 |
commit | 6d438496833a1b9ad40baf9d46d8cea6d1913d35 (patch) | |
tree | 6c3900e28bfbdaafd3de0d12a69b2510dad7897b | |
parent | 82305517b4aa4a6af197159ad0ca4691c1739822 (diff) | |
download | buildstream-6d438496833a1b9ad40baf9d46d8cea6d1913d35.tar.gz |
_artifactcache/artifactcache.py: Write the cache_size file atomicallytristan/atomic-cache-size-file-1.2
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.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py index adfc07748..654b675a2 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() |