Commit 9ec8e00c authored by James Ennis's avatar James Ennis
Browse files

artifactcache.py: Allow ArtifactCache to handle pulling/pushing refs

With the addition of the artifact subcommands, which are able to
process artifact refs, we should not have to rely on CASCache
internals to handle artifacts. This commit ensures that the
pulling/pushing of elements (and their cache keys) is handled
by ArtifactCache.
parent 0ba54bc4
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -661,7 +661,7 @@ class ArtifactCache():
                display_key = element._get_brief_display_key()
                element.status("Pulling artifact {} <- {}".format(display_key, remote.spec.url))

                if self.cas.pull(ref, remote, progress=progress, subdir=subdir, excluded_subdirs=excluded_subdirs):
                if self.pull_ref(ref, remote, progress=progress, subdir=subdir, excluded_subdirs=excluded_subdirs):
                    element.info("Pulled artifact {} <- {}".format(display_key, remote.spec.url))
                    if subdir:
                        # Attempt to extract subdir into artifact extract dir if it already exists
@@ -681,6 +681,23 @@ class ArtifactCache():

        return False

    # pull_ref():
    #
    # Pull artifact from one of the configured remote repositories.
    #
    # Args:
    #     ref (str): The ref to pull
    #     progress (callable): The progress callback, if any
    #     subdir (str): The optional specific subdir to pull
    #     excluded_subdirs (list): The optional list of subdirs to not pull
    #
    # Returns:
    #   (bool): True if pull was successful, False if artifact was not available
    #
    def pull_ref(self, ref, remote, *, progress=None, subdir=None, excluded_subdirs=None):
        return self.cas.pull(ref, remote, progress=progress, subdir=subdir, excluded_subdirs=excluded_subdirs)


    # pull_tree():
    #
    # Pull a single Tree rather than an artifact.