mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-01 20:31:12 +00:00
Avoid attempting rename in copy fallback path (#1546)
## Summary This _could_ fix https://github.com/astral-sh/uv/issues/1454, but I'm not sure. I was able to replicate by forcing a bunch of error states. But, in short, if we fail to hardlink on the initial copy due to a file existing, and then fail _again_, we fallback to copying. But if we copy, then the tempfile doesn't exist, and so the `fs_err::rename(&tempfile, &out_path)?;` will fail with "File not found". This PR just ensures that the cases are explicitly mutually exclusive: we only attempt to rename if the hardlink succeeded.
This commit is contained in:
parent
8050370717
commit
4e0b6f8f84
1 changed files with 3 additions and 2 deletions
|
|
@ -416,11 +416,12 @@ fn hardlink_wheel_files(
|
|||
// Removing and recreating would lead to race conditions.
|
||||
let tempdir = tempdir_in(&site_packages)?;
|
||||
let tempfile = tempdir.path().join(entry.file_name());
|
||||
if fs::hard_link(path, &tempfile).is_err() {
|
||||
if fs::hard_link(path, &tempfile).is_ok() {
|
||||
fs_err::rename(&tempfile, &out_path)?;
|
||||
} else {
|
||||
fs::copy(path, &out_path)?;
|
||||
attempt = Attempt::UseCopyFallback;
|
||||
}
|
||||
fs_err::rename(&tempfile, &out_path)?;
|
||||
} else {
|
||||
fs::copy(path, &out_path)?;
|
||||
attempt = Attempt::UseCopyFallback;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue