mirror of
https://github.com/pvlnes/homelab.git
synced 2026-04-05 16:01:45 +00:00
16 lines
361 B
Python
16 lines
361 B
Python
import json
|
|
from pathlib import Path
|
|
|
|
STATE_FILE = Path("/data/state.json")
|
|
|
|
def load_state():
|
|
if not STATE_FILE.exists():
|
|
return set(), False
|
|
data = json.loads(STATE_FILE.read_text())
|
|
return set(data.get("known_ids", [])), True
|
|
|
|
def save_state(ids):
|
|
STATE_FILE.write_text(json.dumps({
|
|
"known_ids": sorted(ids)
|
|
}, indent=2))
|