summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-05-08 11:24:00 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-05-08 11:30:57 +0000
commitccd99277c0c7ab0d272e540a47380cea9f03d3b6 (patch)
treeaea972be4409885ab7ac309aaf42eac0da3e1b20
parent1abee6882d38439e88e509e13f6c008bc26f5646 (diff)
downloadmorph-ccd99277c0c7ab0d272e540a47380cea9f03d3b6.tar.gz
Fix LocalArtifactCache.list_contents() returning bad values
The OSFS.walkfiles() method returns file paths inside the cachedir, but LocalArtifactCache.list_contents() expected file names (with no trailing slash). The last digit of the cache key was also being removed. TODO: check if `morph gc` still works
-rw-r--r--morphlib/localartifactcache.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/morphlib/localartifactcache.py b/morphlib/localartifactcache.py
index 341bbb56..10ddd638 100644
--- a/morphlib/localartifactcache.py
+++ b/morphlib/localartifactcache.py
@@ -120,8 +120,9 @@ class LocalArtifactCache(object):
'''
CacheInfo = collections.namedtuple('CacheInfo', ('artifacts', 'mtime'))
contents = collections.defaultdict(lambda: CacheInfo(set(), 0))
- for filename in self.cachefs.walkfiles():
- cachekey = filename[:63]
+ for filepath in self.cachefs.walkfiles():
+ filename = os.path.basename(filepath)
+ cachekey = filename[:64]
artifact = filename[65:]
artifacts, max_mtime = contents[cachekey]
artifacts.add(artifact)