Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a recursive watcher for inotify; per my suggestion in [1] it uses the "/..." syntax in the path to indicate recursive watches, similar to how Go tools work: w, _ := fsnotify.NewWatcher() w.Add("some/dir/...") This will watch "some/dir" as well as any subdirectories of "some/dir". The upshot of using a syntax like this is that we can: 1. With AddRecursive(path string) adding new Add* methods would become hard; for example AddMask("path", fsnotify.Create) to only get CREATE events; we'd then also have to add AddMaskRecursive(). Plus we'd have to add a RemoveRecursive() as well. 2. With Watcher.SetRecursive() like in #339 it's not possible to add some paths recursively and others non-recursively, which may be useful in some cases. Also, it makes it a bit easier to accept user input; in the CLI or config you can set "dir/..." and just pass that as-is to fsnotify, without applications having to write special code. For other watchers it will return ErrRecursionUnsupported for now; Windows support is already mostly finished in #339, and kqueue can be added in much the same way as inotify in a future PR. I also moved all test helpers to helper_test.go, and added a bunch of "shell-like" functions so you're not forever typing error checks and filepath.Join(). The new "eventCollector" is also useful in tests to conveniently collect a slice of events. TODO: - Also support recursion in Remove(), and deal with paths added with "...". I just updated the documentation but didn't actually implement anything. - A few test cases don't seem quite right; want to get #470 merged first as it really confuses things. - Maybe think of a few more test cases. [1]: #339 (comment)
- Loading branch information
Showing
7 changed files
with
392 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.