diff options
| author | Jim MacArthur <jim.macarthur@codethink.co.uk> | 2018-06-29 16:15:07 +0100 |
|---|---|---|
| committer | Jim MacArthur <jim.macarthur@codethink.co.uk> | 2018-06-29 16:15:07 +0100 |
| commit | 86d7bbd75bc09ac25eea56204ef84632291ea899 (patch) | |
| tree | a1dfa29b2c739ae53c96e7b640f6a2386570aad5 | |
| parent | 1524fc476a5de503b899a2fb845d59a35552f5c4 (diff) | |
| download | buildstream-86d7bbd75bc09ac25eea56204ef84632291ea899.tar.gz | |
cascache.py: Add pull_key_only
| -rw-r--r-- | buildstream/_artifactcache/cascache.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/buildstream/_artifactcache/cascache.py b/buildstream/_artifactcache/cascache.py index b95d38e9f..dce6a90b0 100644 --- a/buildstream/_artifactcache/cascache.py +++ b/buildstream/_artifactcache/cascache.py @@ -215,6 +215,29 @@ class CASCache(ArtifactCache): remotes_for_project = self._remotes[element._get_project()] return any(remote.spec.push for remote in remotes_for_project) + + def pull_key_only(self, key, size_bytes, project): + """ Like pull but doesn't need an element and takes a key instead of a ref""" + + for remote in self._remotes[project]: + try: + remote.init() + + tree = remote_execution_pb2.Digest() + tree.hash = key + tree.size_bytes = size_bytes + + self._fetch_directory(remote, tree) + + # no need to pull from additional remotes + return True + + except grpc.RpcError as e: + if e.code() != grpc.StatusCode.NOT_FOUND: + raise + + return False + def pull(self, element, key, *, progress=None): ref = self.get_artifact_fullname(element, key) |
