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

Need to watch for files only - is there an API? #476

Open
Shelim opened this issue Apr 23, 2023 · 3 comments
Open

Need to watch for files only - is there an API? #476

Shelim opened this issue Apr 23, 2023 · 3 comments

Comments

@Shelim
Copy link

Shelim commented Apr 23, 2023

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?

@0xpr03
Copy link
Member

0xpr03 commented Apr 23, 2023

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.

@0xpr03
Copy link
Member

0xpr03 commented Apr 23, 2023

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.

@Shelim
Copy link
Author

Shelim commented Apr 29, 2023

Thank you for the explanation. I think I just copy pollwatcher itself and implement missing functionalities myself

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

No branches or pull requests

2 participants