models: Fix cache expiration logic in fetcher.py

Ensure the cache is treated as expired when last_sync is zero. This prevents potential issues with uninitialized or missing sync timestamps, enhancing reliability.
This commit is contained in:
DevTekVE
2025-01-09 10:51:17 +01:00
parent 04ddb10c1d
commit 9e6656fd2e
+1 -1
View File
@@ -92,7 +92,7 @@ class ModelCache:
"""Checks if the cache has expired"""
current_time = int(time.monotonic() * 1e9)
last_sync = int(self.params.get(self._LAST_SYNC_KEY, encoding="utf-8") or 0)
return (current_time - last_sync) >= self.cache_timeout
return last_sync == 0 or (current_time - last_sync) >= self.cache_timeout
def get(self) -> tuple[dict, bool]:
"""