summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/buildstream/_artifact.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/buildstream/_artifact.py b/src/buildstream/_artifact.py
index 9d24f8245..8e8def29b 100644
--- a/src/buildstream/_artifact.py
+++ b/src/buildstream/_artifact.py
@@ -90,6 +90,18 @@ class Artifact:
return CasBasedDirectory(self._cas, digest=buildtree_digest)
+ # get_sources():
+ #
+ # Get a virtual directory for the artifact sources
+ #
+ # Returns:
+ # (Directory): The virtual directory object
+ #
+ def get_sources(self):
+ sources_digest = self._get_field_digest("sources")
+
+ return CasBasedDirectory(self._cas, digest=sources_digest)
+
# get_logs():
#
# Get the paths of the artifact's logs
@@ -233,6 +245,22 @@ class Artifact:
artifact = self._get_proto()
return bool(str(artifact.buildtree))
+ # cached_sources()
+ #
+ # Check if artifact is cached with sources.
+ #
+ # Returns:
+ # (bool): True if artifact is cached with sources, False if sources
+ # are not available.
+ #
+ def cached_sources(self):
+
+ sources_digest = self._get_field_digest("sources")
+ if sources_digest:
+ return self._cas.contains_directory(sources_digest, with_files=True)
+ else:
+ return False
+
# load_public_data():
#
# Loads the public data from the cached artifact