From 9e6656fd2e289fd919e1a752409fecf0d8b8133f Mon Sep 17 00:00:00 2001 From: DevTekVE Date: Thu, 9 Jan 2025 10:51:17 +0100 Subject: [PATCH] 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. --- sunnypilot/models/fetcher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sunnypilot/models/fetcher.py b/sunnypilot/models/fetcher.py index 67f7efbae..451092ab4 100644 --- a/sunnypilot/models/fetcher.py +++ b/sunnypilot/models/fetcher.py @@ -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]: """