Avoid race when unpacking wheels (#593)

## Summary

If someone else beats us to the unzip, we should let them win.

We already have a check for this at the top of the unzip method, but
it's also possible that two source distributions get built in parallel
that both try to unpack the same build dependency.
This commit is contained in:
Charlie Marsh 2023-12-08 12:46:19 -05:00 committed by GitHub
parent 5ae3a8b1cb
commit cbe1cb4229
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -59,7 +59,15 @@ impl Unzipper {
download.unzip(staging.path())?; download.unzip(staging.path())?;
// Move the unzipped wheel into the cache,. // Move the unzipped wheel into the cache,.
fs_err::rename(staging.into_path(), download.target())?; if let Err(err) = fs_err::rename(staging.into_path(), download.target()) {
// If another thread already unpacked the wheel, we can ignore the error.
return if download.target().is_dir() {
warn!("Wheel is already unpacked: {}", download.remote());
Ok(download.target().to_path_buf())
} else {
Err(err.into())
};
}
Ok(download.target().to_path_buf()) Ok(download.target().to_path_buf())
} }