summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2020-01-23 14:15:55 +0100
committerJürg Billeter <j@bitron.ch>2020-02-11 21:08:59 +0100
commit3669dcd8ed57ccb0849858302c1d9887b05afb54 (patch)
tree02da31ba228a0a26c73f6a6ea64fc36dac465de3
parent03870cca054bace542833f9e07fab00edfa971fd (diff)
downloadbuildstream-3669dcd8ed57ccb0849858302c1d9887b05afb54.tar.gz
_artifact.py: Add helper methods for new sources field
-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