Skip to content

fix(config): use atomic write for config file updates#53

Merged
missuo merged 1 commit into
missuo:mainfrom
erning:fix/atomic-config-write
Apr 6, 2026
Merged

fix(config): use atomic write for config file updates#53
missuo merged 1 commit into
missuo:mainfrom
erning:fix/atomic-config-write

Conversation

@erning

@erning erning commented Apr 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • config_set(), migrate_config_v1_to_v2(), and normalize_hotkey_config() write config.yaml directly with std::fs::write(). If the process crashes mid-write, the config file can be left truncated/corrupted.
  • Extract an atomic_write_file() helper that writes to a .yaml.tmp sibling then renames into place, ensuring the config file is always either the old or new version.

Test plan

  • cargo test -p koe-core — 27 tests pass
  • Change a setting via the wizard, verify config.yaml is updated correctly
  • Confirm no .yaml.tmp file lingers after normal operation

Write config to a .yaml.tmp sibling file then rename into place.
This prevents config corruption if the process crashes mid-write.
Applied to config_set, migrate_config_v1_to_v2, and
normalize_hotkey_config.
@missuo missuo merged commit c20a07b into missuo:main Apr 6, 2026
@erning erning deleted the fix/atomic-config-write branch April 7, 2026 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants