summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Ennis <james.ennis@codethink.com>2019-01-24 17:29:47 +0000
committerJames Ennis <james.ennis@codethink.com>2019-02-13 09:35:45 +0000
commit77345317405c680064487817e7da622dc7bdd5ad (patch)
treed574bb2b7684dfed21016ee80101a573ae4f1c4e
parentfcc799179e17f67a8bc516f53c06d5094d20fe13 (diff)
downloadbuildstream-77345317405c680064487817e7da622dc7bdd5ad.tar.gz
_artifactcache.py: Add get_artifacts_log() method
A CasBasedDirectory object of an artifacts logs can be obtained with ArtifactCache.get_artifacts_log(). This ultimately calls CASCache.get_top_level_dir() to obtain a CasBasedDirectory of an artifact's subdirectory (or subdirectories).
-rw-r--r--buildstream/_artifactcache.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/buildstream/_artifactcache.py b/buildstream/_artifactcache.py
index a766582ad..b3ca01618 100644
--- a/buildstream/_artifactcache.py
+++ b/buildstream/_artifactcache.py
@@ -28,6 +28,7 @@ from . import utils
from . import _yaml
from ._cas import CASRemote, CASRemoteSpec
+from .storage._casbaseddirectory import CasBasedDirectory
CACHE_SIZE_FILE = "cache_size"
@@ -821,6 +822,22 @@ class ArtifactCache():
self.cas.link_ref(oldref, newref)
+ # get_artifact_logs():
+ #
+ # Get the logs of an existing artifact
+ #
+ # Args:
+ # ref (str): The ref of the artifact
+ #
+ # Returns:
+ # logsdir (CasBasedDirectory): A CasBasedDirectory containing the artifact's logs
+ #
+ def get_artifact_logs(self, ref):
+ descend = ["logs"]
+ cache_id = self.cas.resolve_ref(ref, update_mtime=True)
+ vdir = CasBasedDirectory(self.cas, cache_id).descend(descend)
+ return vdir
+
################################################
# Local Private Methods #
################################################