From a72f19a6c30cbb389f3d5916d205942d2ba965da Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Tue, 4 Jun 2019 08:20:55 +0900 Subject: Only clear cache when view paths are specified Currently, `clear_cache_if_necessary` is executed even if view paths are not set like `rails console`. If the watcher class is `EventedFileUpdateChecker` and the watch directories are empty, the application root directory will watch. This is because listen uses the current directory as the default watch directory. https://github.com/guard/listen/blob/8d85b4cd5788592799adea61af14a29bf2895d87/lib/listen/adapter/config.rb#L13 As a result, `node_modules` also watch. This cause a warning of `listen`. Ref: https://github.com/rails/rails/pull/36377#issuecomment-498399576 --- actionview/lib/action_view/cache_expiry.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'actionview') diff --git a/actionview/lib/action_view/cache_expiry.rb b/actionview/lib/action_view/cache_expiry.rb index 3d8ffeaefb..7cdc2e9982 100644 --- a/actionview/lib/action_view/cache_expiry.rb +++ b/actionview/lib/action_view/cache_expiry.rb @@ -22,6 +22,8 @@ module ActionView def clear_cache_if_necessary @mutex.synchronize do watched_dirs = dirs_to_watch + return if watched_dirs.empty? + if watched_dirs != @watched_dirs @watched_dirs = watched_dirs @watcher = @watcher_class.new([], watched_dirs) do -- cgit v1.2.3