Mercurial > libervia-backend
changeset 3209:f14eb24328d0
core (memory/cache): purge cache metadata when the referenced file doesn't exist
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 06 Mar 2020 18:19:03 +0100 |
parents | 4f00fdf11445 |
children | fedec192a83f |
files | sat/memory/cache.py |
diffstat | 1 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/sat/memory/cache.py Fri Mar 06 18:19:03 2020 +0100 +++ b/sat/memory/cache.py Fri Mar 06 18:19:03 2020 +0100 @@ -81,8 +81,15 @@ .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))