Skip to content

Problem when moving watched directory with inotify #172

@chmike

Description

@chmike

When renaming/moving a watched directory that is not inside a watched directory, fsnotify informs of the renaming, but:

  1. doesn't update the name stored internally
  2. keeps tracking changes inside the directory
  3. report names starting with the old name for changes inside it
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions