summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buildstream/_cas/cascache.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/buildstream/_cas/cascache.py b/buildstream/_cas/cascache.py
index 1092f6f75..5a6251815 100644
--- a/buildstream/_cas/cascache.py
+++ b/buildstream/_cas/cascache.py
@@ -22,7 +22,6 @@ import itertools
import os
import stat
import errno
-import tempfile
import uuid
import contextlib
@@ -130,7 +129,7 @@ class CASCache():
else:
return dest
- with tempfile.TemporaryDirectory(prefix='tmp', dir=self.tmpdir) as tmpdir:
+ with utils._tempdir(prefix='tmp', dir=self.tmpdir) as tmpdir:
checkoutdir = os.path.join(tmpdir, ref)
self._checkout(checkoutdir, tree)
@@ -375,7 +374,7 @@ class CASCache():
for chunk in iter(lambda: tmp.read(4096), b""):
h.update(chunk)
else:
- tmp = stack.enter_context(tempfile.NamedTemporaryFile(dir=self.tmpdir))
+ tmp = stack.enter_context(utils._tempnamedfile(dir=self.tmpdir))
# Set mode bits to 0644
os.chmod(tmp.name, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
@@ -843,7 +842,7 @@ class CASCache():
# already in local repository
return objpath
- with tempfile.NamedTemporaryFile(dir=self.tmpdir) as f:
+ with utils._tempnamedfile(dir=self.tmpdir) as f:
remote._fetch_blob(digest, f)
added_digest = self.add_object(path=f.name, link_directly=True)
@@ -853,7 +852,7 @@ class CASCache():
def _batch_download_complete(self, batch):
for digest, data in batch.send():
- with tempfile.NamedTemporaryFile(dir=self.tmpdir) as f:
+ with utils._tempnamedfile(dir=self.tmpdir) as f:
f.write(data)
f.flush()
@@ -950,7 +949,7 @@ class CASCache():
def _fetch_tree(self, remote, digest):
# download but do not store the Tree object
- with tempfile.NamedTemporaryFile(dir=self.tmpdir) as out:
+ with utils._tempnamedfile(dir=self.tmpdir) as out:
remote._fetch_blob(digest, out)
tree = remote_execution_pb2.Tree()