core (memory/cache): purge cache metadata when the referenced file doesn't exist

This commit is contained in:
Goffi 2020-03-06 18:19:03 +01:00
commit 4b69d89138

View file

@ -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))