Skip to content

Commit 6b020c8

Browse files
committed
fix windows
1 parent 563de55 commit 6b020c8

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

src/packaging/file_finder.rs

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,34 @@ use walkdir::WalkDir;
1111

1212
use crate::{metadata::Output, recipe::parser::GlobVec};
1313

14-
use super::{PackagingError, file_mapper};
14+
use super::{PackagingError, file_mapper, normalize_path_for_comparison};
1515

1616
/// A wrapper around PathBuf that implements case-insensitive hashing and equality
1717
/// when the filesystem is case-insensitive
1818
#[derive(Debug, Clone)]
1919
struct CaseInsensitivePath {
20-
path: PathBuf,
20+
path: String,
2121
}
2222

2323
impl CaseInsensitivePath {
24-
fn new(path: PathBuf) -> Self {
25-
Self { path }
24+
fn new(path: &Path) -> Self {
25+
Self {
26+
path: normalize_path_for_comparison(path, true).unwrap(),
27+
}
2628
}
2729
}
2830

2931
impl std::hash::Hash for CaseInsensitivePath {
3032
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
3133
// Convert to lowercase string for case-insensitive hashing
32-
self.path.to_string_lossy().to_lowercase().hash(state);
34+
self.path.hash(state);
3335
}
3436
}
3537

3638
impl PartialEq for CaseInsensitivePath {
3739
fn eq(&self, other: &Self) -> bool {
3840
// Case-insensitive comparison
39-
self.path.to_string_lossy().to_lowercase() == other.path.to_string_lossy().to_lowercase()
41+
self.path == other.path
4042
}
4143
}
4244

@@ -109,6 +111,7 @@ fn check_is_case_sensitive() -> Result<bool, io::Error> {
109111
fn find_new_files(
110112
current_files: &HashSet<PathBuf>,
111113
previous_files: &HashSet<PathBuf>,
114+
prefix: &Path,
112115
is_case_sensitive: bool,
113116
) -> HashSet<PathBuf> {
114117
if is_case_sensitive {
@@ -118,17 +121,23 @@ fn find_new_files(
118121
// On case-insensitive filesystems, use case-aware comparison
119122
let previous_case_aware: HashSet<CaseInsensitivePath> = previous_files
120123
.iter()
121-
.map(|p| CaseInsensitivePath::new(p.clone()))
124+
.map(|p| {
125+
CaseInsensitivePath::new(p.strip_prefix(prefix).expect("File should be in prefix"))
126+
})
122127
.collect();
123128

124-
current_files
125-
.iter()
126-
.filter(|current_path| {
127-
let current_case_aware = CaseInsensitivePath::new((*current_path).clone());
128-
!previous_case_aware.contains(&current_case_aware)
129+
let current_files = current_files
130+
.clone()
131+
.into_iter()
132+
.filter(|p| {
133+
// Only include files that are not in the previous set
134+
!previous_case_aware.contains(&CaseInsensitivePath::new(
135+
p.strip_prefix(prefix).expect("File should be in prefix"),
136+
))
129137
})
130-
.cloned()
131-
.collect()
138+
.collect::<HashSet<_>>();
139+
140+
current_files
132141
}
133142
}
134143

@@ -171,7 +180,12 @@ impl Files {
171180
let current_files = record_files(prefix)?;
172181

173182
// Use case-aware difference calculation
174-
let mut difference = find_new_files(&current_files, &previous_files, fs_is_case_sensitive);
183+
let mut difference = find_new_files(
184+
&current_files,
185+
&previous_files,
186+
prefix,
187+
fs_is_case_sensitive,
188+
);
175189

176190
// Filter by files glob if specified
177191
if !files.is_empty() {

src/packaging/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub fn contains_prefix_binary(file_path: &Path, prefix: &Path) -> Result<bool, P
3333
// TODO on Windows check both ascii and utf-8 / 16?
3434
#[cfg(target_family = "windows")]
3535
{
36-
tracing::warn!("Windows is not supported yet for binary prefix checking.");
36+
tracing::debug!("Windows is not supported yet for binary prefix checking.");
3737
Ok(false)
3838
}
3939

0 commit comments

Comments
 (0)