diff options
author | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2014-07-03 13:48:20 +0000 |
---|---|---|
committer | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2014-07-03 17:57:40 +0000 |
commit | 966a00afa89f35c0d19c32549c69b059bf5c533f (patch) | |
tree | d864551bc3874ccdba794cb425f46dbb107846ab | |
parent | 2aab22d4452c38ce500a6c3c336b36b19923fb46 (diff) | |
download | morph-966a00afa89f35c0d19c32549c69b059bf5c533f.tar.gz |
Use the whole chunk morphology to compute cache keys
Change the cache key computer to use all (useful) fields in the chunk
morphology to compute the cache key for a chunk. Previously, changing a
chunk morphology meant the chunk ref would need to change, but now this
is not the case, so the cache key needs to change when the morphology
does.
-rw-r--r-- | morphlib/cachekeycomputer.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/morphlib/cachekeycomputer.py b/morphlib/cachekeycomputer.py index ca374436..3fabac25 100644 --- a/morphlib/cachekeycomputer.py +++ b/morphlib/cachekeycomputer.py @@ -101,11 +101,16 @@ class CacheKeyComputer(object): kind = artifact.source.morphology['kind'] if kind == 'chunk': - keys['build-mode'] = artifact.source.build_mode - keys['prefix'] = artifact.source.prefix - keys['tree'] = artifact.source.tree - keys['split-rules'] = [(a, [rgx.pattern for rgx in r._regexes]) - for (a, r) in artifact.source.split_rules] + morphology = artifact.source.morphology + morph_dict = dict((k, morphology[k]) for k in morphology.keys()) + ignored_fields = ['description'] + for field in ignored_fields: + if field in morph_dict: + del morph_dict[field] + + checksum = hashlib.sha1() + self._hash_thing(checksum, morph_dict) + keys['morphology-sha1'] = checksum.hexdigest() elif kind in ('system', 'stratum'): morphology = artifact.source.morphology le_dict = dict((k, morphology[k]) for k in morphology.keys()) |