Mercurial > libervia-backend
comparison sat/memory/cache.py @ 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 | 08151c103636 |
children | fedec192a83f |
comparison
equal
deleted
inserted
replaced
3208:4f00fdf11445 | 3209:f14eb24328d0 |
---|---|
79 log.warning( | 79 log.warning( |
80 _("Invalid cache metadata at {path}") | 80 _("Invalid cache metadata at {path}") |
81 .format(path=cache_file)) | 81 .format(path=cache_file)) |
82 continue | 82 continue |
83 | 83 |
84 if eol < time.time(): | 84 filepath = self.getPath(filename) |
85 filepath = self.getPath(filename) | 85 |
86 if not filepath.exists(): | |
87 log.warning(_( | |
88 "cache {cache_file!r} references an inexisting file: {filepath!r}" | |
89 ).format(cache_file=str(cache_file), filepath=str(filepath))) | |
90 log.debug("purging cache with missing file") | |
91 cache_file.unlink() | |
92 elif eol < time.time(): | |
86 log.debug( | 93 log.debug( |
87 "purging expired cache {filepath!r} (expired for {time}s)" | 94 "purging expired cache {filepath!r} (expired for {time}s)" |
88 .format(filepath=str(filepath), time=int(time.time() - eol)) | 95 .format(filepath=str(filepath), time=int(time.time() - eol)) |
89 ) | 96 ) |
90 cache_file.unlink() | 97 cache_file.unlink() |