Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions notify/src/inotify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,13 @@ fn add_watch_by_event(
return;
}

let mut current = parent;
while let Some(parent) = current.parent() {
if let Some(watch_mode) = watches.get(parent)
for ancestor in parent.ancestors().skip(1) {
if let Some(watch_mode) = watches.get(ancestor)
&& watch_mode.recursive_mode == RecursiveMode::Recursive
{
add_watches.push((path.to_owned(), true, is_file_without_hardlinks));
return;
}
current = parent;
}
}

Expand Down Expand Up @@ -256,16 +254,11 @@ impl EventLoop {
return true;
}

let mut current = parent;
while let Some(parent) = current.parent() {
if let Some(watch_mode) = watches.get(parent)
&& watch_mode.recursive_mode == RecursiveMode::Recursive
{
return true;
}
current = parent;
}
false
parent.ancestors().skip(1).any(|ancestor| {
watches
.get(ancestor)
.is_some_and(|watch_mode| watch_mode.recursive_mode == RecursiveMode::Recursive)
})
}

#[expect(clippy::too_many_lines)]
Expand Down
15 changes: 5 additions & 10 deletions notify/src/kqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,11 @@ impl EventLoop {
return true;
}

let mut current = parent;
while let Some(parent) = current.parent() {
if let Some(watch_mode) = watches.get(parent)
&& watch_mode.recursive_mode == RecursiveMode::Recursive
{
return true;
}
current = parent;
}
false
parent.ancestors().skip(1).any(|ancestor| {
watches
.get(ancestor)
.is_some_and(|watch_mode| watch_mode.recursive_mode == RecursiveMode::Recursive)
})
}

#[expect(clippy::too_many_lines)]
Expand Down