summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-03-13 14:00:28 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2019-03-27 16:24:32 +0000
commit670ef09f9a5c8b3d162d4da5e08463dc818545f8 (patch)
tree3115bf3397d8c3bdacdf64b28168fca76c312895
parent76cc36c3686b5f440903c9ac56eb2ee07c3e2ffd (diff)
downloadbuildstream-670ef09f9a5c8b3d162d4da5e08463dc818545f8.tar.gz
_artifactcache.py: Add fetch_missing_blobs() method
-rw-r--r--buildstream/_artifactcache.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/buildstream/_artifactcache.py b/buildstream/_artifactcache.py
index 3ca6c6e60..2e544d223 100644
--- a/buildstream/_artifactcache.py
+++ b/buildstream/_artifactcache.py
@@ -439,3 +439,24 @@ class ArtifactCache(BaseCache):
cache_id = self.cas.resolve_ref(ref, update_mtime=True)
vdir = CasBasedDirectory(self.cas, digest=cache_id).descend('logs')
return vdir
+
+ # fetch_missing_blobs():
+ #
+ # Fetch missing blobs from configured remote repositories.
+ #
+ # Args:
+ # project (Project): The current project
+ # missing_blobs (list): The Digests of the blobs to fetch
+ #
+ def fetch_missing_blobs(self, project, missing_blobs):
+ for remote in self._remotes[project]:
+ if not missing_blobs:
+ break
+
+ remote.init()
+
+ # fetch_blobs() will return the blobs that are still missing
+ missing_blobs = self.cas.fetch_blobs(remote, missing_blobs)
+
+ if missing_blobs:
+ raise ArtifactError("Blobs not found on configured artifact servers")