Skip to content

Commit a738020

Browse files
claudebranchseer
authored andcommitted
Clean fspy paths at strip_path_prefix site, simplify downstream code
Move path_clean::PathClean normalization into the strip_path_prefix callback so all fspy-reported paths are clean from the start. This removes the need for separate cleaning in the negative glob filter and in PostRunFingerprint::create. https://claude.ai/code/session_01PR9yhnScRoVoHUcviV47u5
1 parent 713bf28 commit a738020

2 files changed

Lines changed: 8 additions & 24 deletions

File tree

crates/vite_task/src/session/execute/fingerprint.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,9 @@ impl PostRunFingerprint {
8484
let inferred_inputs = inferred_path_reads
8585
.par_iter()
8686
.map(|(relative_path, path_read)| {
87-
// Clean the absolute path to normalize `..` from fspy-tracked paths
88-
// (e.g., `packages/sub-pkg/../shared/dist/output.js`).
89-
let cleaned_abs =
90-
path_clean::PathClean::clean(base_dir.join(relative_path).as_path());
91-
92-
// Derive a cleaned workspace-relative key so stored paths are normalized
93-
let clean_key = cleaned_abs
94-
.strip_prefix(base_dir.as_path())
95-
.ok()
96-
.and_then(|p| RelativePathBuf::new(p).ok())
97-
.unwrap_or_else(|| relative_path.clone());
98-
99-
let full_path = Arc::<AbsolutePath>::from(base_dir.join(&clean_key));
87+
let full_path = Arc::<AbsolutePath>::from(base_dir.join(relative_path));
10088
let fingerprint = fingerprint_path(&full_path, *path_read)?;
101-
Ok((clean_key, fingerprint))
89+
Ok((relative_path.clone(), fingerprint))
10290
})
10391
.collect::<anyhow::Result<HashMap<_, _>>>()?;
10492

crates/vite_task/src/session/execute/spawn.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,17 @@ pub async fn spawn_with_tracking(
190190
let path_writes = &mut path_accesses.path_writes;
191191

192192
for access in termination.path_accesses.iter() {
193+
// Clean the path to normalize `..` components since fspy may report
194+
// paths like `packages/sub-pkg/../shared/dist/output.js`.
193195
let relative_path = access.path.strip_path_prefix(workspace_root, |strip_result| {
194196
let Ok(stripped_path) = strip_result else {
195197
return None;
196198
};
197199
// On Windows, paths are possible to be still absolute after stripping the workspace root.
198200
// For example: c:\workspace\subdir\c:\workspace\subdir
199201
// Just ignore those accesses.
200-
RelativePathBuf::new(stripped_path).ok()
202+
let cleaned = path_clean::PathClean::clean(stripped_path);
203+
RelativePathBuf::new(cleaned).ok()
201204
});
202205

203206
let Some(relative_path) = relative_path else {
@@ -211,15 +214,8 @@ pub async fn spawn_with_tracking(
211214
}
212215

213216
// Filter against resolved negative globs (both are workspace-root-relative).
214-
// Clean the relative path to normalize `..` components since fspy may report
215-
// paths like `packages/sub-pkg/../shared/dist/output.js`.
216-
if !resolved_negatives.is_empty() {
217-
let cleaned = path_clean::PathClean::clean(relative_path.as_path());
218-
if let Some(cleaned_str) = cleaned.to_str()
219-
&& resolved_negatives.iter().any(|neg| neg.is_match(cleaned_str))
220-
{
221-
continue;
222-
}
217+
if resolved_negatives.iter().any(|neg| neg.is_match(relative_path.as_str())) {
218+
continue;
223219
}
224220

225221
if access.mode.contains(AccessMode::READ) {

0 commit comments

Comments
 (0)