This commit is contained in:
2026-03-16 16:08:57 -03:00
parent 6635c861c8
commit 847d3bd384
6 changed files with 590 additions and 15 deletions

View File

@@ -65,8 +65,18 @@ logger = logging.getLogger("zeus-email-poller")
# ---------------------------------------------------------------------------
def load_state() -> dict:
if os.path.exists(STATE_FILE):
with open(STATE_FILE) as f:
return json.load(f)
try:
with open(STATE_FILE) as f:
content = f.read().strip()
if not content:
return {"processed_uids": [], "last_check": None}
data = json.loads(content)
if isinstance(data, dict):
return data
else:
logger.warning(f"State file corrupted (not a dict), resetting")
except (json.JSONDecodeError, IOError) as e:
logger.warning(f"State file corrupted: {e}, resetting")
return {"processed_uids": [], "last_check": None}