From d8c8fcae38b3efda783ee066e50c6e0c900219dc Mon Sep 17 00:00:00 2001 From: Bas Zalmstra Date: Thu, 12 Dec 2024 17:06:01 +0100 Subject: [PATCH] fix: check reflink support before linking (#979) --- Cargo.toml | 2 +- crates/rattler/src/install/mod.rs | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a64de0d68..cee85eaf0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -107,7 +107,7 @@ plist = "1" purl = { version = "0.1.3", features = ["serde"] } quote = "1.0.37" rand = "0.8.5" -reflink-copy = "0.1.19" +reflink-copy = "0.1.20" regex = "1.11.1" reqwest = { version = "0.12.9", default-features = false } reqwest-middleware = "0.4.0" diff --git a/crates/rattler/src/install/mod.rs b/crates/rattler/src/install/mod.rs index ef1a17965..cc81a6b4d 100644 --- a/crates/rattler/src/install/mod.rs +++ b/crates/rattler/src/install/mod.rs @@ -300,9 +300,16 @@ pub async fn link_package( match options.allow_hard_links { Some(value) => ready(value).left_future(), None => can_create_hardlinks(target_dir, package_dir).right_future(), - } + }, ); - let allow_ref_links = options.allow_ref_links.unwrap_or(allow_hard_links); + let allow_ref_links = options.allow_ref_links.unwrap_or_else(|| { + match reflink_copy::check_reflink_support(package_dir, target_dir) { + Ok(reflink_copy::ReflinkSupport::Supported) => true, + Ok(reflink_copy::ReflinkSupport::NotSupported) => false, + Ok(reflink_copy::ReflinkSupport::Unknown) => allow_hard_links, + Err(_) => false, + } + }); // Determine the platform to use let platform = options.platform.unwrap_or(Platform::current());