From 10d6998819c75e8be8d01bec6c98a666b6ee4e08 Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Wed, 3 Oct 2018 21:57:43 +0900 Subject: _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. --- buildstream/_artifactcache/cascache.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(): -- cgit v1.2.1