mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Fallback to copy if hardlinking failed (#237)
This commit is contained in:
parent
1529def563
commit
35d6bd761b
2 changed files with 16 additions and 3 deletions
|
@ -361,6 +361,9 @@ fn hardlink_wheel_files(
|
|||
) -> Result<usize, Error> {
|
||||
let mut count = 0usize;
|
||||
|
||||
// Avoid causing the same error for every file
|
||||
let mut use_copy_fallback = false;
|
||||
|
||||
// Walk over the directory.
|
||||
for entry in walkdir::WalkDir::new(&wheel) {
|
||||
let entry = entry?;
|
||||
|
@ -375,8 +378,15 @@ fn hardlink_wheel_files(
|
|||
// Hardlink the file, unless it's the `RECORD` file, which we modify during installation.
|
||||
if entry.path().ends_with("RECORD") {
|
||||
fs::copy(entry.path(), &out_path)?;
|
||||
} else if use_copy_fallback {
|
||||
fs::copy(entry.path(), &out_path)?;
|
||||
} else {
|
||||
fs::hard_link(entry.path(), &out_path)?;
|
||||
let hard_link_result = fs::hard_link(entry.path(), &out_path);
|
||||
// Once https://github.com/rust-lang/rust/issues/86442 is stable, use that
|
||||
if hard_link_result.is_err() {
|
||||
fs::copy(entry.path(), &out_path)?;
|
||||
use_copy_fallback = true;
|
||||
}
|
||||
}
|
||||
|
||||
count += 1;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use anyhow::{Error, Result};
|
||||
use anyhow::{Context, Error, Result};
|
||||
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
|
||||
|
||||
use pep440_rs::Version;
|
||||
|
@ -47,7 +47,10 @@ impl<'a> Installer<'a> {
|
|||
self.venv.interpreter_info().simple_version(),
|
||||
);
|
||||
|
||||
install_wheel_rs::linker::install_wheel(&location, wheel.path(), self.link_mode)?;
|
||||
install_wheel_rs::linker::install_wheel(&location, wheel.path(), self.link_mode)
|
||||
.with_context(|| {
|
||||
format!("Failed to install {} {}", wheel.name(), wheel.version())
|
||||
})?;
|
||||
|
||||
if let Some(reporter) = self.reporter.as_ref() {
|
||||
reporter.on_install_progress(wheel.name(), wheel.version());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue