From d23d4f3ea20dd12b4819fe6bb5eea1f44e34ea90 Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Thu, 30 Aug 2018 21:02:27 +0900 Subject: _artifactcache/artifactcache.py: Write the cache_size file atomically 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. --- buildstream/_artifactcache/artifactcache.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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() -- cgit v1.2.1