summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2020-09-24 16:00:27 +0200
committerJürg Billeter <j@bitron.ch>2020-09-28 14:30:39 +0200
commitba659a8b5e1947a501ca566d850b5e481ea828d8 (patch)
tree2ad3b99ab9d5431131ab7f33160f7a45b811d14a
parent5ad83f6a9a5d8e2cac01ee9afdfe07d363151270 (diff)
downloadbuildstream-ba659a8b5e1947a501ca566d850b5e481ea828d8.tar.gz
_artifact.py: Add pull() method
-rw-r--r--src/buildstream/_artifact.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/buildstream/_artifact.py b/src/buildstream/_artifact.py
index f6af294a4..c110e57f0 100644
--- a/src/buildstream/_artifact.py
+++ b/src/buildstream/_artifact.py
@@ -465,6 +465,32 @@ class Artifact:
assert self._proto
self._cached = True
+ # pull()
+ #
+ # Pull artifact from remote artifact repository into local artifact cache.
+ #
+ # Args:
+ # pull_buildtrees (bool): Whether to pull buildtrees or not
+ #
+ # Returns: True if the artifact has been downloaded, False otherwise
+ #
+ def pull(self, *, pull_buildtrees):
+ artifacts = self._context.artifactcache
+
+ pull_key = self.get_extract_key()
+
+ if not artifacts.pull(self._element, pull_key, pull_buildtrees=pull_buildtrees):
+ return False
+
+ self.set_cached()
+
+ # Add reference for the other key (weak key when pulling with strong key,
+ # strong key when pulling with weak key)
+ for key in self.get_metadata_keys():
+ artifacts.link_key(self._element, pull_key, key)
+
+ return True
+
# load_proto()
#
# Returns: