Skip to content

Keep unreadable config.toml from being overwritten (roadmap C-01) - #16

Open
CodyKoInABox wants to merge 3 commits into
mainfrom
cursor/guard-unreadable-config-f039
Open

CodyKoInABox wants to merge 3 commits into
mainfrom
cursor/guard-unreadable-config-f039

Conversation

@CodyKoInABox

Copy link
Copy Markdown
Owner

Problem

If config.toml fails to load (invalid TOML, unknown key, or a config_version this build does not support), Rustshot starts with in-memory defaults. Later, remember_overlay_preferences saved the editor tool, color, or stroke width whenever they differed from those defaults. That replaced the original file with the defaults, without a backup. SUPPORT.md says unsupported newer schemas are preserved without being overwritten, so this contradicted the documentation.

Changes

  • The app tracks the failed load (config_recovery). While it is set, editor-preference changes stay in memory and are not written.
  • The first explicit Settings save after a failed load copies the unreadable file to config.toml.bak. If that name is taken, it uses config.toml.bak.<timestamp> instead of overwriting the earlier backup. The flag clears only after a successful save.
  • The load-failure dialog says the existing file will not be overwritten until Settings is saved.
  • The preference-saving logic moves into remember_editor_preferences, which takes the save step as a closure so it can be tested.

Tests

  • unreadable_config_is_not_overwritten_by_editor_preferences: writes config_version = 2, changes the remembered tool, and checks the file is byte-identical afterward.
  • readable_config_persists_editor_preferences: the normal path still saves.
  • unused_backup_path_never_replaces_an_existing_backup

Not run locally: the Linux host cannot build the Windows dependencies. CI runs on Windows.

Open in Web Open in Cursor 

cursoragent and others added 2 commits November 6, 2026 18:17
When config.toml fails to load, Rustshot runs on defaults in memory. Saving
remembered editor preferences then replaced the original file, dropping
unknown keys or a newer schema version without a backup.

- Track the failed load in the app state and skip automatic saves while set.
- Back up the unreadable file to config.toml.bak (or a timestamped name if
  that exists) before the first explicit Settings save repairs it.
- Add regression tests: the file stays byte-identical after an editor
  preference change, and readable configs still persist.

Co-authored-by: codykoinabox <codykoinabox@gmail.com>
Current stable clippy flags chunks_exact with a constant chunk size
(chunks_exact_to_as_chunks), and CI runs clippy with -D warnings. Switch
the affected pixel loops to slice::as_chunks, which is stable since Rust
1.88, the crate's MSRV. Behavior is unchanged: both forms drop the same
partial tail, which is always empty for valid RGBA buffers.

Co-authored-by: codykoinabox <codykoinabox@gmail.com>
The bin target hits the same chunks_exact_to_as_chunks lint that the library
targets already hit, so CI's clippy -D warnings still fails without it.

Co-authored-by: codykoinabox <codykoinabox@gmail.com>

This branch has not been deployed

No deployments
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