fix: lock state and settings file updates#4946
Conversation
6c613d6 to
8ba412f
Compare
|
Squashed into one commit now. I reran the locked-file regression plus fmt/diff checks after the rewrite. |
|
@ychampion The CI is failing but it's probably not your fault; it might be due to an upstream update of Rust. Since we are at it, would you mind fixing the clippy warnings in a separate commit? Many thanks in advance 🙏 |
@djc I see your point but refactoring PRs can always follow this one... I would prefer not putting too much pressure on first-time contributors in fixing our pre-existing issues WRT code organization, if you agree 🙏 |
I might agree but I guess I put less value on seemingly drive-by contributions that seem clearly LLM-assisted. |
|
Done in 42a5b3e as a separate commit. Validation:
|
|
@djc That's fair. I can move the raw helpers back beside the existing |
Okay, let's keep it as is for now. Would be nice if you can clean up single caller Please rebase, since the Clippy fixes are already on |
Constraint: rustup state and settings files can be touched by concurrent rustup processes. Rejected: truncating on open | The exclusive lock must be held first. Confidence: high Scope-risk: narrow Directive: Keep locked-file read/write changes focused on state/settings persistence semantics. Tested: cargo test --features test locked_file_round_trip_truncates_previous_contents; cargo test --features test settings::tests; cargo test --features test --test test_bonanza notify_release_hint; cargo check --all-targets --features test; cargo clippy --all-targets --features test -- -D warnings; cargo fmt --all -- --check; git diff --check Not-tested: full test_bonanza suite
42a5b3e to
702fcb5
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Rebased onto current |
@ychampion Would you mind evaluating the proposed clean-up of the |
Summary
state.tomlandsettings.tomlreads and writes.Why
Fixes #4942. These files can be touched by concurrent rustup processes, so writes now take an exclusive lock before truncating and reads take a shared lock.
Validation
cargo test --features test locked_file_round_trip_truncates_previous_contents— passedcargo test --features test settings::tests— passedcargo test --features test --test test_bonanza notify_release_hint— passedcargo check --all-targets --features test— passedcargo clippy --all-targets --features test -- -D warnings— passedcargo fmt --all -- --check— passedgit diff --check— passed