Open evanpurkhiser opened 6 years ago
If I add a symlink to a directory it would be awesome if it's tree could be watched as well.
This intentionally is not possible - os watchers (inotify, FSEvents) report events using canonical paths.
If a symlink to other directory tree was added then notify would start to report events coming from other tree that was not explicitly watched by a user, which may create confusion. The current approach is to leave decision whether to watch symlinked tree or not to the user.
Unrelated - from you snippet I learned there's a filepath.EvalSymlinks
function. We could use it instead of the canonical()
one that notify currently implements on its own.
The current approach is to leave decision whether to watch symlinked tree or not to the user.
There's no type of configuration for this though correct? The user would have to attach watchers to any symlinks added into the tree.
If a symlink to other directory tree was added then notify would start to report events coming from other tree that was not explicitly watched by a user, which may create confusion.
As far as I could tell, from my brief experiment, it actually reported paths relative to the root watched directory
There's no type of configuration for this though correct?
Unfortunately no, current API was built with minimal configuration in mind, in fact there's no configuration at all. Right now we regret a bit this decision and we were previously planning to introduce (backward-compatible) v2 API with actual configuration.
As far as I could tell, from my brief experiment, it actually reported paths relative to the root watched directory.
I'm speaking off the top of my head, so I might be wrong. The relative paths might be true for inotify, but not for FSEvents and ReadDirChangesW (macOS / windows).
If I add a symlink to a directory it would be awesome if it's tree could be watched as well.
I suspect this might be difficult to support in a cross compatible way without additional work. For the non-recursive linux inotify, it looks like it's just the addition of resolving the symlink in here:
https://github.com/rjeczalik/notify/blob/7e20c15e6693a7d6ad269a94b70ed68bc4a875a7/node.go#L82-L87
(would end up looking something like this)