提交 767cec04 编写于 作者: A Alan Tan

Revert "Use `app.config.file_watcher` for watcher in `RoutesReloader`"

This reverts commit 28e44f47.

A limitation of Listen is that it currently only supports watching directories.
Therefore, watching `config/routes.rb` will end up watching the entire `config` directory
if we use the evented file watcher. This causes problems especially if symlinks are present
in the `config` directory.
上级 3ae38069
......@@ -341,7 +341,7 @@ def require_environment! #:nodoc:
end
def routes_reloader #:nodoc:
@routes_reloader ||= RoutesReloader.new(file_watcher: config.file_watcher)
@routes_reloader ||= RoutesReloader.new
end
# Returns an array of file paths appended with a hash of
......
......@@ -9,11 +9,10 @@ class RoutesReloader
attr_accessor :eager_load
delegate :execute_if_updated, :execute, :updated?, to: :updater
def initialize(file_watcher: ActiveSupport::FileUpdateChecker)
def initialize
@paths = []
@route_sets = []
@eager_load = false
@file_watcher = file_watcher
end
def reload!
......@@ -27,7 +26,7 @@ def reload!
private
def updater
@updater ||= @file_watcher.new(paths) { reload! }
@updater ||= ActiveSupport::FileUpdateChecker.new(paths) { reload! }
end
def clear!
......
......@@ -184,8 +184,11 @@ def self.counter; 2; end
test "does not reload constants on development if custom file watcher always returns false" do
add_to_config <<-RUBY
config.cache_classes = false
config.file_watcher = Class.new(ActiveSupport::FileUpdateChecker) do
config.file_watcher = Class.new do
def initialize(*); end
def updated?; false; end
def execute; end
def execute_if_updated; false; end
end
RUBY
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册