Skip to content

fix(config): make settings persistence atomic #36

Description

@postigodev

Summary

AppConfig::save() writes directly to the final config path with fs::write, unlike binding persistence which already uses a temporary file plus atomic replacement.

A process interruption or write failure can therefore leave config.json truncated or otherwise unreadable. save_settings also synchronizes the OS autostart state before persisting the config, so a later config-write failure can leave the OS setting and stored preference out of sync.

Expected outcome

Make settings persistence durable and keep external side effects consistent with the stored config.

Acceptance criteria

  • write config through a temporary file and replace the destination only after a successful write/sync
  • clean up temporary files on failure
  • preserve the existing AppData migration behavior
  • order or compensate autostart changes so a failed config save does not silently leave OS state inconsistent with persisted settings
  • return actionable errors when persistence or autostart synchronization fails
  • add regression coverage for safe config replacement where practical

Possible direction

Reuse or extract the same safe-write pattern already used by bindings.json rather than maintaining two subtly different persistence strategies.

Likely files

  • crates/core/src/config/mod.rs
  • apps/tauri/src-tauri/src/commands.rs
  • potentially a small shared persistence helper

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

    backendRust or native backend workbugSomething is broken or incorrect

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions