mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
- Catch an exception on lstat()
This commit is contained in:
@ -59,9 +59,12 @@ class Cache(plugins.Plugin):
|
|||||||
ctime = datetime.now(tz=UTC)
|
ctime = datetime.now(tz=UTC)
|
||||||
cache_to_delete = list()
|
cache_to_delete = list()
|
||||||
for cache_file in pathlib.Path(self.cache_dir).glob("*.apcache"):
|
for cache_file in pathlib.Path(self.cache_dir).glob("*.apcache"):
|
||||||
mtime = datetime.fromtimestamp(cache_file.lstat().st_mtime, tz=UTC)
|
try:
|
||||||
if (ctime - mtime).total_seconds() > 60 * 5:
|
mtime = datetime.fromtimestamp(cache_file.lstat().st_mtime, tz=UTC)
|
||||||
cache_to_delete.append(cache_file)
|
if (ctime - mtime).total_seconds() > 60 * 5:
|
||||||
|
cache_to_delete.append(cache_file)
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
if cache_to_delete:
|
if cache_to_delete:
|
||||||
logging.info(f"[CACHE] Cleaning {len(cache_to_delete)} files")
|
logging.info(f"[CACHE] Cleaning {len(cache_to_delete)} files")
|
||||||
for cache_file in cache_to_delete:
|
for cache_file in cache_to_delete:
|
||||||
|
Reference in New Issue
Block a user