Skip to content

bug: settings.json is written in place; a power cut can wipe the wall's configuration #352

Open

Description

@BernardJen

What

saveSettings in input_viewer_electron/src/main/index.js:207 writes with a plain fs.writeFileSync(settingsPath, ...). A power cut or crash mid-write leaves a truncated file.

On the next start loadSettings fails to parse it, logs to the console, and returns the defaults. The next debounced save then overwrites the broken file with those defaults. Input names, enabled flags, the default input, device assignments, the remote-keyboard key and Art-Net settings are all gone, with only a console line as evidence.

Fix

  • Write to settings.json.tmp and rename it over the real file (atomic on the same volume).
  • On a parse failure, move the bad file aside (settings.json.corrupt-<time>) before anything can overwrite it, and log it to the file log.

The egui prototype in #346 does both (input_viewer_egui/src/settings.rs).


Found while reconstructing the Electron app's decisions as ADRs for the egui port (#346, docs/adr/open-questions.md). Line numbers are from main at 787375b (v3.4.1).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions