-
Notifications
You must be signed in to change notification settings - Fork 247
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
No way to listen to a directory non-recursively #111
Comments
Good point, we could add an option like |
Yeah, that would be sufficient. |
Great, I'll work on it once the Listen rewrite will be done. |
According to @stephanvane's comment on sass/sass#764, this is fixed in listen 1.3.1. Is that accurate? |
It is not, I'm still working on the rewrite for the v2.0 version. That feature should be added in v2.x |
Sorry about that, guess I misread some comments :(. Good luck on the rewrite! |
@stephanvane rewrite is mostly done now, feel free to give a try to the |
Listen 2.0.0 has just been released, so I would have some time to implement this feature. Is it still needed? Isn't it something that could be done with the |
The goal here is to make watching individual files as efficient as possible. Right now they're O(n) for the size of the entire recursive contents of the directory containing them, which is very bad. If we could disable recursive watching, that could at least make them O(n) for the number of sibling files, which would be a marked improvement. It sounds like |
Performance really depends on which adapter is used. Polling adapter will really benefit of an I would prefer to not add new options that only apply to a specific adapter (i.e.: only rb-inotify adapter). |
Being able to listen non-recursively or listen to a single file is generally useful. A library like listen is most helpful to me as a user when it exposes functionality that's useful and takes care of implementing it in terms of underlying primitives itself. That said, yes, rb-inotify supports non-recursive scanning. In fact, inotify itself only supports non-recursive scanning, and rb-inotify builds its recursive scanning interface on top of this by automatically listening and un-listening to new directories. Since non-recursive scanning is useful and can be implemented efficiently with at least the inotify and polling adapters, it seems like a clear case for new functionality. |
Ok good arguments, I agree that we can add this option even if it'll more effective on polling and inotify. On rb-inotify I only the the Thanks for your feedback! |
👍 I just thought of a use for this feature. Set-up some configuration when a dir is created, and takedown that config when it is removed. I'll directly use rb-inotify for this project. |
TL;DR; - will likely be implemented soon once it's worked out for every platform This is a little tough to do, since every adapter does things differently:
@thibaudgg - any advice about rb-fsevent and recursion? Can it be turned off? Is it worth it? Would watching dirs (and new ones) explicitly and without recursion be a big performance hit? |
@e2 I don't think it can be turned off and I don't think it makes more sense to doing so. It should be fine like that. |
Thanks for the answer, @thibaudgg - much appreciated. Crap. So my idea of making recursion option os-independent goes out the window. Implementing I'll work something out... |
TL;DR the actual work required to support this instead of using a regexp outweighs the costs in any use case I can think of @nex3 - I'm closing this, because:
And the workarounds are trivial:
If I'm wrong, and there's a real-life use case where above workarounds -- especially the ignore rules or symlinking won't do -- and where spending lots of hours to put this into Listen makes sense ... feel free to reopen this. And of course, pull requests are more than welcome ;) |
I've redefined this problem as not being able to prevent listen from scanning ignored directories: #274 (Users shouldn't care about recursion - they should care only about setting up proper ignore rules). |
`spring-watcher-listen` watch application root by default. https://github.com/jonleighton/spring-watcher-listen/blob/c4bfe15805867e229588e4b776a7b87438137094/lib/spring/watcher/listen.rb#L58 This is necessary to watch the file (e.g. `.ruby-version`) in the application root. By this `node_modules` also be watched, and it is a possibility to be shown a warning by `listen`. Related to rails#32700, rails#34912, rails/webpacker#1990. `listen` watches directory recursive by default, and it cannot avoid it. guard/listen#111 So If this warning happens, the only workaround the user can do is remove the gem. The issue is likely to occur more frequently in Rails 6 because `rails new` runs `webpacker:install` by default. Because of such a state, I think that we should not recommend to use `spring-watcher-listen`. Spring has polling watcher, restart process works without this `spring-watcher-listen`. Because of polling base, CPU load may be higher than listen base. Still I think that it is better than the warning comes out.
As of 1.0.0, when listening to a directory, all subdirectories of that directory are also automatically listened to. Sometimes this isn't the desired behavior, but there's no (obvious) way around it other than manually ignoring all changes in subdirectories.
The text was updated successfully, but these errors were encountered: