Harden main loop and store; by-id device default, BOARD_TZ
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
1 parent
8649d3abd0
commit
44a1b3cf8c
7 files changed
+100
-30
No files matched your search
@@ -54,9 +54,10 @@ def cache_path(data_dir, cfg: LineConfig) -> Path:
|
||||
|
||||
def _read_fetched(data_dir: Path) -> dict[str, str]:
|
||||
try:
|
||||
return json.loads((data_dir / FETCHED_FILE).read_text(encoding="utf-8"))
|
||||
data = json.loads((data_dir / FETCHED_FILE).read_text(encoding="utf-8"))
|
||||
except (OSError, ValueError):
|
||||
return {}
|
||||
return data if isinstance(data, dict) else {}
|
||||
|
||||
|
||||
def _write_atomic(path: Path, text: str) -> None:
|
||||
@@ -105,7 +106,7 @@ def is_stale(lines, data_dir, now: datetime, max_age: timedelta = MAX_AGE) -> bo
|
||||
for cfg in lines:
|
||||
try:
|
||||
when = datetime.fromisoformat(fetched[cfg.label])
|
||||
except (KeyError, ValueError):
|
||||
except (KeyError, ValueError, TypeError):
|
||||
return True
|
||||
if now - when > max_age:
|
||||
return True
|
||||
|
||||
Reference in new issue
Block a user