mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00

fix bug: corruption when cargo killed while writing ### What does this PR try to resolve? fix #11386, superseding #12362 ### How should we test and review this PR? Added unit test showing basic equivalency to existing `write(path, content)`. Full test suite should exercise write. Added tests for cargo add and remove. These are timing tests, so take a bit of time to run. 5-10s each. They may not fail every time, but do so regularly. Making the change to these two writes seems to prevent me from failing these tests at all. ### Additional information This uses tempfile::persist which was an existing dependency. atomicwrites crate, an alternative option for this fix, indicates `tempfile::persist` is the same thing. Since we already use tempfile as a dep, I stuck with that.