diff options
Diffstat (limited to 'config/hypr/UserScripts/Weather.py')
| -rwxr-xr-x | config/hypr/UserScripts/Weather.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/config/hypr/UserScripts/Weather.py b/config/hypr/UserScripts/Weather.py index 14256cfd..6061f696 100755 --- a/config/hypr/UserScripts/Weather.py +++ b/config/hypr/UserScripts/Weather.py @@ -224,6 +224,12 @@ def read_api_cache() -> Optional[Dict[str, Any]]: data = json.load(f) # Use ensure_dict for safety data_dict = ensure_dict(data) + + # Invalidate cache if units mismatch + if data_dict.get("units") != UNITS: + log_debug(f"Cache units '{data_dict.get('units')}' mismatch current '{UNITS}'.") + return None + timestamp_val = data_dict.get("timestamp", 0) timestamp = coerce_float(timestamp_val) or 0 if (time.time() - timestamp) <= CACHE_TTL_SECONDS: @@ -238,6 +244,7 @@ def write_api_cache(payload: Dict[str, Any]) -> None: try: ensure_cache_dir() payload["timestamp"] = time.time() + payload["units"] = UNITS with API_CACHE_PATH.open("w", encoding="utf-8") as f: json.dump(payload, f) except Exception as e: |
