Skip to content
Snippets Groups Projects
Commit 4342bf9b authored by James Ennis's avatar James Ennis
Browse files

_artifactcache.py: Get the logs of an artifact

A CasBasedDirectory object of an artifacts logs can be obtained
with ArtifactCache.get_artifacts_log(). This ultimately calls
CASCache.get_top_level_dir() to obtained a CasBasedDirectory
of an artifact's subdirectory (or subdirectories).
parent 0e95c6f7
No related branches found
No related tags found
No related merge requests found
......@@ -833,6 +833,20 @@ 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"]
return self.cas.get_toplevel_dir(ref, descend)
################################################
# Local Private Methods #
################################################
......
......@@ -32,6 +32,7 @@ from .._protos.buildstream.v2 import buildstream_pb2
from .. import utils
from .._exceptions import CASCacheError
from ..storage._casbaseddirectory import CasBasedDirectory
from .casremote import BlobNotFound, _CASBatchRead, _CASBatchUpdate
......@@ -587,6 +588,22 @@ class CASCache():
reachable = set()
self._reachable_refs_dir(reachable, tree, update_mtime=True)
# get_toplevel_dir()
#
# Return a CasBasedDirectory object of the specified sub_directories
#
# Args:
# ref (str): The artifact ref
# descend (list): A list of strings of artifact subdirectories
#
# Returns:
# (CasBasedDirectory): The CasBasedDirectory object
#
def get_toplevel_dir(self, ref, descend):
cache_id = self.resolve_ref(ref, update_mtime=True)
vdir = CasBasedDirectory(self, cache_id).descend(descend)
return vdir
################################################
# Local Private Methods #
################################################
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment