Skip to content

Back up and recover the state file instead of silently starting fresh #295

Description

@rfsbraz

Description

StateManager.load() (app/state.py) handles a corrupt or version-mismatched state file by logging a warning and returning empty state. There is no .bak, no recovery attempt, and no migration path for STATE_VERSION changes - a bump wipes everyone's state on upgrade.

Losing state resets every pending leaving-soon timer (items get their full duration again) and re-sends already-sent leaving-soon notifications. Not an over-deletion risk (the duration filter fails safe), but real user surprise and notification spam.

Proposed Fix

  • Keep a .bak copy on every successful save; on corrupt read, attempt recovery from it before falling back to empty
  • Add a version migration path so a STATE_VERSION bump migrates instead of wiping
  • Log loudly (and notify) when state is actually reset, since timers restarted

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions