From 07bc258bbd0a07fd035ae8a1e5e2b564724b32f6 Mon Sep 17 00:00:00 2001 From: Fabio Lissi Date: Mon, 2 Nov 2026 11:37:52 -0600 Subject: [PATCH] Avoid case probes for unrelated Batch paths --- crates/engine/src/cmd/file_cmds/paths.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/cmd/file_cmds/paths.rs b/crates/engine/src/cmd/file_cmds/paths.rs index 1aead2eaec..642389ed3d 100644 --- a/crates/engine/src/cmd/file_cmds/paths.rs +++ b/crates/engine/src/cmd/file_cmds/paths.rs @@ -232,12 +232,12 @@ pub(super) fn case_sensitive_destination(path: &std::path::Path) -> Option } #[cfg(any(target_os = "macos", target_os = "windows"))] -fn resolved_paths_match(a: &std::path::Path, b: &std::path::Path, case_sensitive: Option) -> bool { +fn resolved_paths_match(a: &std::path::Path, b: &std::path::Path, case_sensitive: impl FnOnce() -> Option) -> bool { if a == b { return true; } match (a.to_str(), b.to_str()) { - (Some(a_text), Some(b_text)) if a_text.to_lowercase() == b_text.to_lowercase() => !case_sensitive.unwrap_or(false), + (Some(a_text), Some(b_text)) if a_text.to_lowercase() == b_text.to_lowercase() => !case_sensitive().unwrap_or(false), _ => false, } } @@ -246,7 +246,8 @@ fn resolved_paths_match(a: &std::path::Path, b: &std::path::Path, case_sensitive #[test] fn identical_resolved_paths_conflict_on_a_case_sensitive_volume() { let path = std::path::Path::new("/future/result.png"); - assert!(resolved_paths_match(path, path, Some(true))); + assert!(resolved_paths_match(path, path, || Some(true))); + assert!(!resolved_paths_match(path, std::path::Path::new("/future/other.png"), || panic!("unrelated names must not probe the volume"))); } /// Whether two paths would name the same destination even before the file exists. This is used @@ -262,7 +263,7 @@ pub fn same_destination(a: impl AsRef, b: impl AsRef { #[cfg(any(target_os = "windows", target_os = "macos"))] { - if a == b { true } else { resolved_paths_match(&a, &b, case_sensitive_destination(&a)) } + resolved_paths_match(&a, &b, || case_sensitive_destination(&a)) } #[cfg(not(any(target_os = "windows", target_os = "macos")))] {