Need to watch for files only - is there an API?
In my use case, I need to watch for file changes (adding / updating / removing) only (ignoring directories)
The EventKind contains info about the adding/removing files or directories, but in my tests, they are populated in Any field of enum. The Modified field does not contain any info about target item whatsoever.
I tired to filter out resulting paths list by is_file function, and this works... except for removing (as there is no longer file/directory in file system I cannot verify whenever it was a file or a directory).
I looked into Config class in the docs, but I didn't find anything to specify that I want file changes only.
Am I missing something from docs, or is the feature not implemented at all?
There is no API for automatically reporting only changes to files. You have to add each path to the watched ones yourself. Note that this will stop giving you events for newly created files, which is why normally the whole folder is watched.
Adding this API would incur a big overhead for anyone not wanting to filter out folders, as you have to keep a list of folders and paths, even if using inotify and not the pollwatcher.
I would strongly suggest solving this in a library working on top of notify / notify-debouncer.
I think the only backend that would suit this (and your walkdir request) is the pollwatcher backend, as it could be extended to support this without creating much additional overhead.
Thank you for the explanation. I think I just copy pollwatcher itself and implement missing functionalities myself