summaryrefslogtreecommitdiff
path: root/morphlib/artifactcachereference.py
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2012-06-13 17:28:44 +0100
committerRichard Maw <richard.maw@codethink.co.uk>2012-06-14 11:04:36 +0000
commit66aeb24c0c5f15ae340387c11a7850e001735e43 (patch)
tree40003436bca99883b6e5f8c68ada2a496e6bf811 /morphlib/artifactcachereference.py
parent840c4f639bc253bcc8c1d03178e2a4e292f9e9ef (diff)
downloadmorph-66aeb24c0c5f15ae340387c11a7850e001735e43.tar.gz
morphlib.artifactcachereference: store basename
This is not to make it easier, but to make it not miss if the algorithm for generating cache names changes. Strictly speaking it should store the format string for accessing metadata as well to be compatible, but missing an artifact's metadata is less important.
Diffstat (limited to 'morphlib/artifactcachereference.py')
-rw-r--r--morphlib/artifactcachereference.py28
1 files changed, 13 insertions, 15 deletions
diff --git a/morphlib/artifactcachereference.py b/morphlib/artifactcachereference.py
index 4cc73290..d4b239d5 100644
--- a/morphlib/artifactcachereference.py
+++ b/morphlib/artifactcachereference.py
@@ -18,26 +18,24 @@ class ArtifactCacheReference(object):
'''Represent the information needed to retrieve an artifact
The artifact cache doesn't need to know the dependencies or the
- morphology of an artifact, it just needs to know the cache key,
- name and kind.
+ morphology of an artifact, it just needs to know the basename
+
+ The basename could be generated, from the name, cache_key and kind,
+ but if the algorithm changes then morph wouldn't be able to find
+ old artifacts with a saved ArtifactCacheReference.
+
+ Conversely if it generated the basename then old strata wouldn't be
+ able to refer to new chunks, but strata change more often than the chunks.
'''
- def __init__(self, name, cache_key, kind):
- self.name = name
- self.cache_key = cache_key
- self.kind = kind
+ def __init__(self, basename):
+ self._basename = basename
def basename(self):
- return '%s.%s.%s' % (self.cache_key,
- self.kind,
- self.name)
+ return self._basename
def metadata_basename(self, metadata_name):
- return '%s.%s.%s.%s' % (self.cache_key,
- self.kind,
- self.name,
- metadata_name)
+ return '%s.%s' % (self._basename, metadata_name)
@classmethod
def from_artifact(klass, artifact):
- return klass(artifact.name, artifact.cache_key,
- artifact.source.morphology['kind'])
+ return klass(artifact.basename())