Update lib/rb-inotify/notifier.rb #22

Merged
merged 1 commit into from Dec 11, 2012

Conversation

Projects
None yet
2 participants
Contributor

geoffyoungs commented Dec 5, 2012

I ran into a problem caused by an oddly named directory which resulted in the inotify backend for guard reliably crashing out on a rails project.

The follow snippet demonstrates the issue:

require 'rb-inotify'
require 'fileutils'

FileUtils.mkdir_p("test-1/**")

listener = INotify::Notifier.new
listener.watch("test-1", :all_events, :recursive) do |event|
  p event
end

When it encounters a directory named '**', the current code (using Dir.glob) enters an infinite, recursive loop until it throws a SystemStackError, because the directory name is a self-matching glob pattern.

As the code in #watch is only using Dir.glob as a convenient way to get a path, rather than just a list of leafnames, I figure the best solution is to switch to Dir.new?

@geoffyoungs geoffyoungs Update lib/rb-inotify/notifier.rb
Avoid needing to escape glob patterns in directory names
aca1714

nex3 merged commit 28b1f51 into guard:master Dec 11, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment