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
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -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          #
    ################################################
+17 −0
Original line number Diff line number Diff line
@@ -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            #
    ################################################