Skip to content

Commit

Permalink
BSD: Don't send ignored paths to kqueue
Browse files Browse the repository at this point in the history
kqueue requires a file handle for every file and directory being
watched so using Listen in a directory with .git or vendor/bundle
quickly eats up all available file handles.

Since these paths are being ignored by the silencer anyway, prevent
watching these paths to conserve file handles.
  • Loading branch information
jcs committed Apr 23, 2021
1 parent 96c9476 commit 746ad79
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/listen/adapter/bsd.rb
Expand Up @@ -45,7 +45,11 @@ def _configure(directory, &callback)
@callback = callback
# use Record to make a snapshot of dir, so we
# can detect new files
_find(directory.to_s) { |path| _watch_file(path, @worker) }
_find(directory.to_s) { |path|
unless @config.silencer.silenced?(Pathname.new(path).relative_path_from(directory), FileTest.directory?(path) ? :dir : :file)
_watch_file(path, @worker)
end
}
end

def _run
Expand Down

0 comments on commit 746ad79

Please sign in to comment.