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

When watching several directories, only the last is actually watched. #243

Closed
chriseppstein opened this issue Jul 11, 2014 · 7 comments · Fixed by #257
Closed

When watching several directories, only the last is actually watched. #243

chriseppstein opened this issue Jul 11, 2014 · 7 comments · Fixed by #257

Comments

@chriseppstein
Copy link

Listen version: 2.7.9

require 'listen'

dirs_to_watch = %w(
  anotherdir
  somedir
)

listener = Listen.to(*dirs_to_watch) do |added, modified, removed|
  puts "Listen fired callback"
end

listener.start.join

The callback only fires when filesystem events occur on the last directory specified.

@chriseppstein
Copy link
Author

Ruby version: 2.0.0-p247

@thibaudgg
Copy link
Member

@e2 any ideas about that one? https://twitter.com/chriseppstein/status/491276956084621312

@e2
Copy link
Contributor

e2 commented Sep 14, 2014

Works in Linux, so it looks like an issue with darwin/FSEvent adapter (I don't have a Mac to properly test or debug on).

What changed - I needed for each watched directory to have a separate callback (to unify and simplify Listen's adapters). (see https://github.com/guard/listen/blob/master/lib/listen/adapter/darwin.rb)

@thibaudgg - could you confirm I'm using rb-fsevent the right way (i.e. calling watch multiple times on the same FSEvent object before calling run)?

@thibaudgg
Copy link
Member

@e2 calling multiple time watch will not work as it overwrites the @paths list each time,I would only call watch once with the list of directories.

@e2
Copy link
Contributor

e2 commented Sep 15, 2014

@thibaudgg - I need one callback per directory (to later match the original watched directory based on the callback), so the fix is to have multiple FSEvent objects I guess.

Could you review: #257 ?

Ideally I'd add acceptance specs for this (mocking in adapter specs wouldn't make much sense), but looks like way too much work for now - acceptance specs and fixtures currently assume everything happens in a single watched directory.

@e2
Copy link
Contributor

e2 commented Nov 11, 2014

This is still broken after my "fix"- but now only the first directory is watched.

@e2
Copy link
Contributor

e2 commented Nov 13, 2014

Sorry for the delay, folks, but I had to rework how threads are used and finally add some specs to avoid breaking this every again.

flyerhzm pushed a commit to PlatphormCorp/compass that referenced this issue Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants