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

Document that watches are automatically removed for deleted files/directories #238

Closed
cespare opened this issue Mar 7, 2018 · 1 comment · Fixed by #496
Closed

Document that watches are automatically removed for deleted files/directories #238

cespare opened this issue Mar 7, 2018 · 1 comment · Fixed by #496

Comments

@cespare
Copy link
Contributor

cespare commented Mar 7, 2018

I've tested with latest fsnotify (c282820) on Linux/inotify (tested with Ubuntu 16.04) and macOS/kqueue (tested with 10.11.5). I haven't tried Windows.

It's common to want to recursively watch a whole file tree (see #41). This entails:

  1. Whenever a directory in the tree is created, recursively add watches for it and all subdirectories.
  2. When a directory in the tree is deleted, recursively remove watches for it and all subdirectories.

It seems like today, at least on the systems I tested, (2) is unnecessary because fsnotify automatically removes watches for directories that are deleted.

This is great, because it makes it easy to implement recursive watches (the caller just needs to add watches; it doesn't need to keep track of which directories are watched itself). However, this behavior is not documented and not necessarily expected, particularly because it was not the case in the past (see, for instance, #40).

So I think the documentation ought to mention this (and, by corollary, fsnotify ought to commit to maintaining this behavior in the future).

@gdey
Copy link
Contributor

gdey commented Aug 31, 2018

We talked about this at GopherCon 2017, and the decision was that fsnotify will take care of removing the watch. This is going to have to be handled at each driver level. For instance, Windows does not remove the handle properly automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants