From d7f7dac0d743c205b999edc42c9d72aa84de8a06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?fr=C3=A9d=C3=A9ric?= Date: Sun, 16 Feb 2025 20:13:01 +0100 Subject: [PATCH] - Catch an exception on lstat() --- pwnagotchi/plugins/default/cache.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pwnagotchi/plugins/default/cache.py b/pwnagotchi/plugins/default/cache.py index a94bc3dc..64c8f566 100644 --- a/pwnagotchi/plugins/default/cache.py +++ b/pwnagotchi/plugins/default/cache.py @@ -59,9 +59,12 @@ class Cache(plugins.Plugin): ctime = datetime.now(tz=UTC) cache_to_delete = list() for cache_file in pathlib.Path(self.cache_dir).glob("*.apcache"): - mtime = datetime.fromtimestamp(cache_file.lstat().st_mtime, tz=UTC) - if (ctime - mtime).total_seconds() > 60 * 5: - cache_to_delete.append(cache_file) + try: + mtime = datetime.fromtimestamp(cache_file.lstat().st_mtime, tz=UTC) + if (ctime - mtime).total_seconds() > 60 * 5: + cache_to_delete.append(cache_file) + except FileNotFoundError: + pass if cache_to_delete: logging.info(f"[CACHE] Cleaning {len(cache_to_delete)} files") for cache_file in cache_to_delete: