diff options
author | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2015-04-01 14:43:05 +0000 |
---|---|---|
committer | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2015-04-10 13:52:26 +0000 |
commit | b92039f2b4446c90b97f2cfc8f71abfc12d67ba2 (patch) | |
tree | 3894f0ccc9d0d7a79b9a042eae084dce35476f8a | |
parent | daee3628c37798fa60172b6ad026dfd304c858b6 (diff) | |
download | morph-b92039f2b4446c90b97f2cfc8f71abfc12d67ba2.tar.gz |
fixup: Clean up OSTreeArtifactCache
-rw-r--r-- | morphlib/ostreeartifactcache.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/morphlib/ostreeartifactcache.py b/morphlib/ostreeartifactcache.py index fdb7cb5d..ea659c8f 100644 --- a/morphlib/ostreeartifactcache.py +++ b/morphlib/ostreeartifactcache.py @@ -30,9 +30,9 @@ from morphlib.artifactcachereference import ArtifactCacheReference class OSTreeArtifactCache(object): """Class to provide the artifact cache API using an OSTree repo.""" - def __init__(self, cachedir): + def __init__(self, cachedir, mode): repo_dir = os.path.join(cachedir, 'repo') - self.repo = morphlib.ostree.OSTreeRepo(repo_dir) + self.repo = morphlib.ostree.OSTreeRepo(repo_dir, mode=mode) self.cachedir = cachedir def _get_file_from_remote(self, artifact, remote, metadata_name=None): @@ -126,7 +126,7 @@ class OSTreeArtifactCache(object): raise cliapp.AppException('Failed to pull %s from remote ' 'cache.' % ref) - def get(self, artifact, directory=None): + def get(self, artifact, directory=None, status=lambda a: a): """Checkout an artifact from the repo and return its location.""" cache_key, kind, name = artifact.basename().split('.', 2) if kind == 'stratum': @@ -176,7 +176,8 @@ class OSTreeArtifactCache(object): cachekey, kind, name = artifact.basename().split('.', 2) logging.debug('OSTreeArtifactCache: got %s, %s, %s' % (cachekey, kind, name)) - if self._get_artifact_cache_name(artifact) in self.repo.list_refs(): + sha = self.repo.resolve_rev(self._get_artifact_cache_name(artifact)) + if sha: self.repo.touch_ref(self._get_artifact_cache_name(artifact)) return True if kind == 'stratum' and \ |