Repository navigation
Keep unreadable config.toml from being overwritten (roadmap C-01) - #16
Open
CodyKoInABox wants to merge 3 commits into
Open
CodyKoInABox wants to merge 3 commits into
CodyKoInABox wants to merge 3 commits into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
If
config.tomlfails to load (invalid TOML, unknown key, or aconfig_versionthis build does not support), Rustshot starts with in-memory defaults. Later,remember_overlay_preferencessaved 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.mdsays unsupported newer schemas are preserved without being overwritten, so this contradicted the documentation.Changes
config_recovery). While it is set, editor-preference changes stay in memory and are not written.config.toml.bak. If that name is taken, it usesconfig.toml.bak.<timestamp>instead of overwriting the earlier backup. The flag clears only after a successful save.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: writesconfig_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_backupNot run locally: the Linux host cannot build the Windows dependencies. CI runs on Windows.