support reporting events for file system watcher#488
Open
Guest0x0 wants to merge 4 commits into
Open
Conversation
Coverage Report for CI Build 806Coverage increased (+0.08%) to 77.283%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR add a new method
.wait()for@fs.Watcher, which is similar to previous.wait_any(), but return a list of events describing changes on the file system since the last query.Two new options are added to
@fs.Watcher(..)to control event reporting behavior of.wait():When a directory is created/moved inside watched tree or removed/moved outside watched tree:
report_child_event=true, respective create/remove events will be emitted for everything inside that directory. This mode is useful if tracking the exact list of files in desirable.report_child_event=false(the default), only a single event for the directory itself will be emitted, making the watcher less noisyNote that if a rename event is emitted for a directory, events will be reported for changes since the last query for the renamed directory. regardless of the value of
report_child_event.If
report_event_on_init=true(falseby default), the firstwaitcall will return immediately after watcher creation, reporting events describing the initial structure of the watched directory. This is useful for keeping the knowledge of the caller in sync with the watcher. Note that you probably want to setreport_child_event=trueas well in this case.waitperforms rename detection based on the physical ID of files. The rule is:When the watcher cannot serialize the file system changes into simple rename events, for example two files are atomically swapped, a remove event on the old path + a create event on the new path will be created.