-
-
Notifications
You must be signed in to change notification settings - Fork 962
Description
When renaming/moving a watched directory that is not inside a watched directory, fsnotify informs of the renaming, but:
- doesn't update the name stored internally
- keeps tracking changes inside the directory
- report names starting with the old name for changes inside it
- attempt to remove the watch will fail wit an error
This is deduced from reading the code and testings with inotify. I didn't verify if this happens and how fsnotify would precisely behave (e.g 4). I'm confident that this is the case.
The reason is due to inotify not returning the new name of the watched directory (IN_MOVE_SELF). If the watched directory is inside a watched directory than the new name may be obtained, but this needs some smart operation. If that watched directory is moved out of the watched directory, it is still watched, bu the new name is unknown and the watcher can't be removed.
One possible fix is to automatically unwatch moved/renamed directories that aren't inside a watched directory. Watched directories inside another watched directories should be unwatched only when moved out of the enclosing watched directory. This is required because it is not possible to know their new name.
It is yet unclear if it is possible to track directory moves from one watched directory to another watched directory (could be a subdirectory ) I need to do further tests.