mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-08-05 08:16:03 +08:00
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:
@@ -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]:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user