notify-rs / notify

🔭 Cross-platform filesystem notification library for Rust.
https://docs.rs/notify
2.58k stars 207 forks source link

Inconsistent behaviors when root node changes #554

Open bicarlsen opened 5 months ago

bicarlsen commented 5 months ago

There is inconsistent behavior when modifying the root resource (file or directory) in different ways, so wanted to document them. This is not so much an error as documentation of these behavior.

folder/delete folder/rename folder/move file/delete file/rename file/move
Windows Remove(Any) or no event no event no event Remove(Any) Modify(Name(From)) Remove(Any)
macOS Remove(Folder) or Modify(Name(Any)) Modify(Name(Any)) Modify(Name(Any)) Modify(Name(Any)) Modify(Name(Any)) Modify(Name(Any))
Linux Remove(File) or Modify(Name(From)) Modify(Name(From)) Modify(Name(From)) Remove(File) or Modify(Name(From)) Modify(Name(From)) Modify(Name(From))

Details

Windows

macOS

Linux

Note: I performed the tests using notify_debouncer_full

bicarlsen commented 5 months ago

In the cases where a resource's path changes but it is still being tracked and the original path is being emitted, this could lead to confusing behavior.

bicarlsen commented 5 months ago

I made a proof of concept crate that gets a file's path from the id information provided in the file-id crate.

Chaoses-Ib commented 5 months ago

PollWatcher will emit Remove(Any) for all the children and the root folder after the root folder is deleted/renamed/moved. If the folder is created again, Create(Any) will be emitted for the root folder and all the children.