Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix moved directory not being watched #498

Merged
merged 1 commit into from
Jun 21, 2023
Merged

fix moved directory not being watched #498

merged 1 commit into from
Jun 21, 2023

Conversation

sebastiantoh
Copy link
Contributor

Fixes #491

The bug was introduced in 65d6d91#diff-9663de7aadbfa93d9f87e8c0dc5c94855e59fff314c091caa5478b666e404983R258-R264, which calls add_watch_by_event only if the trackers matched.

Prior to 65d6d91, add_watch_by_event was called so long as the event.mask.contains(EventMask::MOVED_TO) regardless of whether the trackers matched

if event.mask.contains(EventMask::MOVED_TO) {
if let Some(e) = self.rename_event.take() {
if e.tracker() == Some(event.cookie as usize) {
self.event_handler.handle_event(Ok(e.clone()));
evs.push(
Event::new(EventKind::Modify(ModifyKind::Name(
RenameMode::To,
)))
.set_tracker(event.cookie as usize)
.add_some_path(path.clone()),
);
evs.push(
Event::new(EventKind::Modify(ModifyKind::Name(
RenameMode::Both,
)))
.set_tracker(event.cookie as usize)
.add_some_path(e.paths.first().cloned())
.add_some_path(path.clone()),
);
} else {
// TODO should it be rename?
evs.push(
Event::new(EventKind::Create(
if event.mask.contains(EventMask::ISDIR) {
CreateKind::Folder
} else {
CreateKind::File
},
))
.add_some_path(path.clone()),
);
}
} else {
// TODO should it be rename?
evs.push(
Event::new(EventKind::Create(
if event.mask.contains(EventMask::ISDIR) {
CreateKind::Folder
} else {
CreateKind::File
},
))
.add_some_path(path.clone()),
);
}
add_watch_by_event(
&path,
&event,
&self.watches,
&mut add_watches,
);
}

@0xpr03
Copy link
Member

0xpr03 commented Jun 21, 2023

Hmm just to confirm: This doesn't change the emitted events ?

cc @dfaust

@0xpr03
Copy link
Member

0xpr03 commented Jun 21, 2023

Besides that: Thanks for investing the time to bisect and fix this!

@dfaust
Copy link
Collaborator

dfaust commented Jun 21, 2023

Thanks @sebastiantoh!
I can confirm the fix.

@0xpr03: No, it only fixes the bug.

@0xpr03 0xpr03 merged commit 0539af8 into notify-rs:main Jun 21, 2023
12 checks passed
@0xpr03 0xpr03 added this to the 6.1.0 milestone Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Directory moved from one watched directory to another is not recursively watched
3 participants