summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-10-03 21:57:43 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-10-03 22:03:56 +0900
commit10d6998819c75e8be8d01bec6c98a666b6ee4e08 (patch)
treed3edd9778af15940967e5c937e96209fc82485fa
parent262e789fca6950bc136a87f9a475d6cf7dd1faa3 (diff)
downloadbuildstream-10d6998819c75e8be8d01bec6c98a666b6ee4e08.tar.gz
_artifactcache/cascache.py: Don't create temporary files in the CAS storage
Use the designated tempdir when creating refs, we expect that temporary files are not created in the storage directory ever, they should be only ever created in the designated temporary directory. This fixes race conditions where utils._get_dir_size() throws an unhandled exception when attempting to stat the file which inadvertantly disappears.
-rw-r--r--buildstream/_artifactcache/cascache.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/buildstream/_artifactcache/cascache.py b/buildstream/_artifactcache/cascache.py
index 14932fba2..ffeccc0b3 100644
--- a/buildstream/_artifactcache/cascache.py
+++ b/buildstream/_artifactcache/cascache.py
@@ -418,7 +418,7 @@ class CASCache(ArtifactCache):
def set_ref(self, ref, tree):
refpath = self._refpath(ref)
os.makedirs(os.path.dirname(refpath), exist_ok=True)
- with utils.save_file_atomic(refpath, 'wb') as f:
+ with utils.save_file_atomic(refpath, 'wb', tempdir=self.tmpdir) as f:
f.write(tree.SerializeToString())
# resolve_ref():