rustup icon indicating copy to clipboard operation
rustup copied to clipboard

Lock download file to avoid races

Open konstin opened this issue 1 month ago • 2 comments

See #4607 for details.

This is one of two possible implementations, the easier one is using a temporary directory or a unique filename to ensure processes don't collide. Using locks has less platform support, but OTOH means that we don't create stray temp files that don't get cleaned up (because we never know if one of those files is actually used by another process).

This does not fix #4607 completely. It only fixed the downloaded, parallel rustup-init calls still fail at the transaction stage.

This PR introduces a LockedFile primitive that's modeled after the uv type of the same name. It's currently very simple and locks forever. We can extend it with a timeout that makes rustup exit after a certain duration and print an error message, instead of an inscrutable waiting without any message.

konstin avatar Nov 19 '25 14:11 konstin

after the uv type of the same name

Would be great if you can a link to it :)

weihanglo avatar Nov 20 '25 00:11 weihanglo

The uv type: https://github.com/astral-sh/uv/blob/fc0cf90795dbfa961f22fc0934a53afc9c13c349/crates/uv-fs/src/lib.rs#L672. I have a branch that adds async timeouts, but that's in review still.

konstin avatar Nov 20 '25 09:11 konstin