summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2020-10-28 09:19:05 +0100
committerJürg Billeter <j@bitron.ch>2020-12-09 14:51:06 +0000
commitc836b7be6feaa0b9f86ab8c0cb5b913b0d8ed0e0 (patch)
treee4c7679ded79f80c478a13a7a878ef00a772efe4
parenta501b0e60f15779be0abb7b074dd6e4944b1a23a (diff)
downloadbuildstream-juerg/cas.tar.gz
Use CASCache.open()juerg/cas
-rw-r--r--src/buildstream/_artifact.py5
-rw-r--r--src/buildstream/_artifactcache.py2
-rw-r--r--src/buildstream/_cas/cascache.py3
-rw-r--r--src/buildstream/_elementsourcescache.py2
-rw-r--r--src/buildstream/sandbox/_sandboxremote.py4
5 files changed, 8 insertions, 8 deletions
diff --git a/src/buildstream/_artifact.py b/src/buildstream/_artifact.py
index b92600a5a..d4a716ff1 100644
--- a/src/buildstream/_artifact.py
+++ b/src/buildstream/_artifact.py
@@ -370,8 +370,9 @@ class Artifact:
# Load the public data from the artifact
artifact = self._get_proto()
- meta_file = self._cas.objpath(artifact.public_data)
- data = _yaml.load(meta_file, shortname="public.yaml")
+ with self._cas.open(artifact.public_data) as meta_file:
+ meta_str = meta_file.read()
+ data = _yaml.load_data(meta_str, file_name="public.yaml")
return data
diff --git a/src/buildstream/_artifactcache.py b/src/buildstream/_artifactcache.py
index 41a620b49..ded87679a 100644
--- a/src/buildstream/_artifactcache.py
+++ b/src/buildstream/_artifactcache.py
@@ -510,7 +510,7 @@ class ArtifactCache(AssetCache):
# Fetch and parse artifact proto
self.cas.fetch_blobs(remote, [artifact_digest])
artifact = artifact_pb2.Artifact()
- with open(self.cas.objpath(artifact_digest), "rb") as f:
+ with self.cas.open(artifact_digest, "rb") as f:
artifact.ParseFromString(f.read())
# Write the artifact proto to cache
diff --git a/src/buildstream/_cas/cascache.py b/src/buildstream/_cas/cascache.py
index b875eecdd..b80460abf 100644
--- a/src/buildstream/_cas/cascache.py
+++ b/src/buildstream/_cas/cascache.py
@@ -543,8 +543,7 @@ class CASCache:
tree = remote_execution_pb2.Tree()
- objpath = self.objpath(digest)
- with open(objpath, "rb") as f:
+ with self.open(digest, "rb") as f:
tree.ParseFromString(f.read())
dirbuffers = [tree.root.SerializeToString()]
diff --git a/src/buildstream/_elementsourcescache.py b/src/buildstream/_elementsourcescache.py
index 9a617b8d6..194f3fd4a 100644
--- a/src/buildstream/_elementsourcescache.py
+++ b/src/buildstream/_elementsourcescache.py
@@ -299,7 +299,7 @@ class ElementSourcesCache(AssetCache):
# Fetch and parse source proto
self.cas.fetch_blobs(remote, [source_digest])
source = source_pb2.Source()
- with open(self.cas.objpath(source_digest), "rb") as f:
+ with self.cas.open(source_digest, "rb") as f:
source.ParseFromString(f.read())
# Write the source proto to cache
diff --git a/src/buildstream/sandbox/_sandboxremote.py b/src/buildstream/sandbox/_sandboxremote.py
index 3302b0dad..ff314adba 100644
--- a/src/buildstream/sandbox/_sandboxremote.py
+++ b/src/buildstream/sandbox/_sandboxremote.py
@@ -380,13 +380,13 @@ class SandboxRemote(SandboxREAPI):
# Forward remote stdout and stderr
if stdout:
if action_result.stdout_digest.hash:
- with open(cascache.objpath(action_result.stdout_digest), "r") as f:
+ with cascache.open(action_result.stdout_digest, "r") as f:
shutil.copyfileobj(f, stdout)
elif action_result.stdout_raw:
stdout.write(str(action_result.stdout_raw, "utf-8", errors="ignore"))
if stderr:
if action_result.stderr_digest.hash:
- with open(cascache.objpath(action_result.stderr_digest), "r") as f:
+ with cascache.open(action_result.stderr_digest, "r") as f:
shutil.copyfileobj(f, stderr)
elif action_result.stderr_raw:
stderr.write(str(action_result.stderr_raw, "utf-8", errors="ignore"))