summaryrefslogtreecommitdiff
path: root/buildstream
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-02-24 12:08:17 +0100
committerJürg Billeter <j@bitron.ch>2019-02-28 12:01:15 +0100
commit64d1e88764b3ad3e3eda830999485f786421f120 (patch)
treed03dec3aba1757d1ba88fc9743d278ed84605ebf /buildstream
parent8be33e19e9c6b989da2c98f64c00a17882af0301 (diff)
downloadbuildstream-64d1e88764b3ad3e3eda830999485f786421f120.tar.gz
_artifactcache.py: Add get_artifact_directory() method
Diffstat (limited to 'buildstream')
-rw-r--r--buildstream/_artifactcache.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/buildstream/_artifactcache.py b/buildstream/_artifactcache.py
index b73304fac..e29379dad 100644
--- a/buildstream/_artifactcache.py
+++ b/buildstream/_artifactcache.py
@@ -444,6 +444,27 @@ class ArtifactCache():
return self.cas.remove(ref)
+ # get_artifact_directory():
+ #
+ # Get virtual directory for cached artifact of the specified Element.
+ #
+ # Assumes artifact has previously been fetched or committed.
+ #
+ # Args:
+ # element (Element): The Element to extract
+ # key (str): The cache key to use
+ #
+ # Raises:
+ # ArtifactError: In cases there was an OSError, or if the artifact
+ # did not exist.
+ #
+ # Returns: virtual directory object
+ #
+ def get_artifact_directory(self, element, key):
+ ref = element.get_artifact_name(key)
+ digest = self.cas.resolve_ref(ref, update_mtime=True)
+ return CasBasedDirectory(self.cas, digest)
+
# extract():
#
# Extract cached artifact for the specified Element if it hasn't