From ccd99277c0c7ab0d272e540a47380cea9f03d3b6 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Thu, 8 May 2014 11:24:00 +0000 Subject: 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 --- morphlib/localartifactcache.py | 5 +++-- 1 file 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) -- cgit v1.2.1