Unverified Commit aa28d0e4 authored by Benjamin Woodruff ‮'s avatar Benjamin Woodruff Committed by GitHub

Turbopack: Minor cleanup from review of #99711 (#99748)

Minor cleanup opportunities I noticed after reviewing
https://fleet-review.vercel.tools/vercel/next.js/pull/99711/changes/ba6208431008d331bb3c738cd32643c61c04f411..18e7c6dee5d4f85aa1c9a9a68a50830fc73b52f8
parent cbc5ea55
...@@ -127,9 +127,6 @@ mod tests { ...@@ -127,9 +127,6 @@ mod tests {
map.insert(PathBuf::from("x/y/z"), 7); map.insert(PathBuf::from("x/y/z"), 7);
map.insert(PathBuf::from("z/a/b"), 8); map.insert(PathBuf::from("z/a/b"), 8);
assert!(map.contains_path_or_children(Path::new("x/y")));
assert!(!map.contains_path_or_children(Path::new("a/b/c/d")));
let parent_path = PathBuf::from("a/b"); let parent_path = PathBuf::from("a/b");
let extracted: Vec<_> = map.extract_path_with_children(&parent_path).collect(); let extracted: Vec<_> = map.extract_path_with_children(&parent_path).collect();
......
...@@ -333,9 +333,9 @@ mod non_recursive_helpers { ...@@ -333,9 +333,9 @@ mod non_recursive_helpers {
root_path: &Path, root_path: &Path,
mut on_restored: impl FnMut(Box<Path>), mut on_restored: impl FnMut(Box<Path>),
) { ) {
// The root directory is always implicitly watched during `DiskWatcher::start_watching`, we let needs_restore = |watched: &BTreeSet<PathBuf>, dir_path: &Path| {
// assume it is never deleted and never needs to be restored. // The root directory is always implicitly watched during `DiskWatcher::start_watching`,
let is_watched = |watched: &BTreeSet<PathBuf>, dir_path: &Path| { // we assume it is never deleted and never needs to be restored.
dir_path != root_path && watched.contains(dir_path) dir_path != root_path && watched.contains(dir_path)
}; };
...@@ -348,7 +348,7 @@ mod non_recursive_helpers { ...@@ -348,7 +348,7 @@ mod non_recursive_helpers {
}; };
if !dir_paths if !dir_paths
.iter() .iter()
.any(|dir_path| is_watched(&watching_state.watched, dir_path)) .any(|dir_path| needs_restore(&watching_state.watched, dir_path))
{ {
return; return;
} }
...@@ -360,13 +360,12 @@ mod non_recursive_helpers { ...@@ -360,13 +360,12 @@ mod non_recursive_helpers {
return; return;
}; };
for dir_path in dir_paths { for dir_path in dir_paths {
if !is_watched(&watching_state.watched, &dir_path) { if needs_restore(&watching_state.watched, &dir_path) {
continue; // TODO: Report diagnostics if this error happens. Report the path as restored even
// on errors, in case the watch was partially restored.
let _ = restore_watched_dir(watching_state, &dir_path, root_path);
on_restored(dir_path);
} }
// TODO: Report diagnostics if this error happens. Report the path as restored even on
// errors, in case the watch was partially restored.
let _ = restore_watched_dir(watching_state, &dir_path, root_path);
on_restored(dir_path);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment