@@ -11,32 +11,34 @@ use walkdir::WalkDir;
11
11
12
12
use crate :: { metadata:: Output , recipe:: parser:: GlobVec } ;
13
13
14
- use super :: { PackagingError , file_mapper} ;
14
+ use super :: { PackagingError , file_mapper, normalize_path_for_comparison } ;
15
15
16
16
/// A wrapper around PathBuf that implements case-insensitive hashing and equality
17
17
/// when the filesystem is case-insensitive
18
18
#[ derive( Debug , Clone ) ]
19
19
struct CaseInsensitivePath {
20
- path : PathBuf ,
20
+ path : String ,
21
21
}
22
22
23
23
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
+ }
26
28
}
27
29
}
28
30
29
31
impl std:: hash:: Hash for CaseInsensitivePath {
30
32
fn hash < H : std:: hash:: Hasher > ( & self , state : & mut H ) {
31
33
// Convert to lowercase string for case-insensitive hashing
32
- self . path . to_string_lossy ( ) . to_lowercase ( ) . hash ( state) ;
34
+ self . path . hash ( state) ;
33
35
}
34
36
}
35
37
36
38
impl PartialEq for CaseInsensitivePath {
37
39
fn eq ( & self , other : & Self ) -> bool {
38
40
// Case-insensitive comparison
39
- self . path . to_string_lossy ( ) . to_lowercase ( ) == other. path . to_string_lossy ( ) . to_lowercase ( )
41
+ self . path == other. path
40
42
}
41
43
}
42
44
@@ -109,6 +111,7 @@ fn check_is_case_sensitive() -> Result<bool, io::Error> {
109
111
fn find_new_files (
110
112
current_files : & HashSet < PathBuf > ,
111
113
previous_files : & HashSet < PathBuf > ,
114
+ prefix : & Path ,
112
115
is_case_sensitive : bool ,
113
116
) -> HashSet < PathBuf > {
114
117
if is_case_sensitive {
@@ -118,17 +121,23 @@ fn find_new_files(
118
121
// On case-insensitive filesystems, use case-aware comparison
119
122
let previous_case_aware: HashSet < CaseInsensitivePath > = previous_files
120
123
. 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
+ } )
122
127
. collect ( ) ;
123
128
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
+ ) )
129
137
} )
130
- . cloned ( )
131
- . collect ( )
138
+ . collect :: < HashSet < _ > > ( ) ;
139
+
140
+ current_files
132
141
}
133
142
}
134
143
@@ -171,7 +180,12 @@ impl Files {
171
180
let current_files = record_files ( prefix) ?;
172
181
173
182
// 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
+ ) ;
175
189
176
190
// Filter by files glob if specified
177
191
if !files. is_empty ( ) {
0 commit comments