diff --git a/sat/memory/cache.py b/sat/memory/cache.py index efded648..d28fb17f 100644 --- a/sat/memory/cache.py +++ b/sat/memory/cache.py @@ -81,8 +81,15 @@ class Cache(object): .format(path=cache_file)) continue - if eol < time.time(): - filepath = self.getPath(filename) + filepath = self.getPath(filename) + + if not filepath.exists(): + log.warning(_( + "cache {cache_file!r} references an inexisting file: {filepath!r}" + ).format(cache_file=str(cache_file), filepath=str(filepath))) + log.debug("purging cache with missing file") + cache_file.unlink() + elif eol < time.time(): log.debug( "purging expired cache {filepath!r} (expired for {time}s)" .format(filepath=str(filepath), time=int(time.time() - eol))