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

Moving subdirectory of recursive watch does not include to and from paths for Modify Name event #626

Open
eighty4 opened this issue Jul 26, 2024 · 1 comment

Comments

@eighty4
Copy link

eighty4 commented Jul 26, 2024

System details

  • OS/Platform name and version: OSX 14.5
  • Rust version (if building from source): rustc --version: 1.80
  • Notify version (or commit hash if building from git):
notify-debouncer-full = {version = "0.3.1", default-features = false}
notify = {version = "6.1.1", default-features = false, features = ["macos_kqueue"]}

Example usage:

https://github.com/eighty4/l3/blob/dev-mode/src/dev.rs#L107

What you did (as detailed as you can)

After setting up a recursive watch on a directory, doing a move directory dispatches a Modify(Name(Any)) and does not include a path for the directory's original path.

self.w.watcher().watch(PathBuf::from("routes"), RecursiveMode::Recursive)?;
mv routes/subdir routes/anotherdir

What you expected

I thought there would be enough context to react to the from path and to path for an operation like moving a directory.

What happened

Using this watch, I would never know that anotherdir was originally subdir, and the app would have to stat every previously tracked file to determine whether they were moved.

@eighty4
Copy link
Author

eighty4 commented Jul 27, 2024

(these following observations and events are with fsevents backend)

I used a recursive directory watch without the debouncer and I got two Modify Name Any events for a mv file on OSX

Modify(Name(Any)) ["/Users/adam/work/eighty4/install.sh/lambdas/routes/foo/lambda.get.env"]
Modify(Name(Any)) ["/Users/adam/work/eighty4/install.sh/lambdas/routes/foo/lambda.post.env"]

It seems like the debouncer squashes those into one event. If the watcher is for a single file and it's moved to a different path and then back to the original path, both Modify Name Anys will have the the watcher is watching with the backend.

If I do multiple mv during the debounce duration, then the path just gets repeated for the watch path and not the path that it was moved to and back from:

Modify(Name(Both)) ["/Users/adam/work/eighty4/install.sh/lambdas/routes/foo/lambda.js", "/Users/adam/work/eighty4/install.sh/lambdas/routes/foo/lambda.js"]

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

No branches or pull requests

1 participant