From 9964c35e2a0355bbbe9d39119de309783d9b383e Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Thu, 9 Apr 2015 16:27:42 +0000 Subject: fixup: Some fixes for ostreeartifactcache --- morphlib/ostreeartifactcache.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'morphlib') diff --git a/morphlib/ostreeartifactcache.py b/morphlib/ostreeartifactcache.py index a7602144..2854a1cc 100644 --- a/morphlib/ostreeartifactcache.py +++ b/morphlib/ostreeartifactcache.py @@ -28,6 +28,7 @@ from gi.repository import GLib import morphlib from morphlib.artifactcachereference import ArtifactCacheReference + class OSTreeArtifactCache(object): """Class to provide the artifact cache API using an OSTree repo.""" @@ -97,9 +98,16 @@ class OSTreeArtifactCache(object): shutil.copy(location, filename) def copy_from_remote(self, artifact, remote): - """Get 'artifact' from remote artifact cache and store it locally.""" + """Get 'artifact' from remote artifact cache and store it locally. + + This takes an Artifact object and a RemoteArtifactCache. Note that + `remote` here is not the same as a `remote` for and OSTree repo. + + """ if remote.method == 'tarball': with self._get_file_from_remote(artifact, remote) as location: + if artifact.basename().split('.', 2)[1] == 'stratum': + self.put_non_ostree_artifact(artifact, location) try: tempdir = tempfile.mkdtemp(dir=self.cachedir) try: @@ -109,9 +117,10 @@ class OSTreeArtifactCache(object): finally: shutil.rmtree(tempdir) except tarfile.ReadError: - # Reading the artifact as a tarball failed, so it must be a - # single file (for example a stratum artifact). - self.put_non_ostree_artifact(artifact, location) + # Reading the tarball failed, and we expected a + # tarball artifact. Something must have gone + # wrong. + raise elif remote.method == 'ostree': self.status(msg='Pulling artifact for %(name)s from remote.', -- cgit v1.2.1