Skip to content

fix moved directory not being watched#498

Merged
0xpr03 merged 1 commit intonotify-rs:mainfrom
sebastiantoh:watch-moved-dir
Jun 21, 2023
Merged

fix moved directory not being watched#498
0xpr03 merged 1 commit intonotify-rs:mainfrom
sebastiantoh:watch-moved-dir

Conversation

@sebastiantoh
Copy link
Copy Markdown
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
Copy Markdown
Member

0xpr03 commented Jun 21, 2023

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

cc @dfaust

@0xpr03
Copy link
Copy Markdown
Member

0xpr03 commented Jun 21, 2023

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

@dfaust
Copy link
Copy Markdown
Member

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
@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