aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2019-06-04 08:20:55 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2019-06-04 08:44:28 +0900
commita72f19a6c30cbb389f3d5916d205942d2ba965da (patch)
tree6cb8c58a55823d5f72a192f51266484f0a35a851 /actionview/lib
parentc926ca46280aee795b98206dd0707a96b9423cc5 (diff)
downloadrails-a72f19a6c30cbb389f3d5916d205942d2ba965da.tar.gz
rails-a72f19a6c30cbb389f3d5916d205942d2ba965da.tar.bz2
rails-a72f19a6c30cbb389f3d5916d205942d2ba965da.zip
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
Diffstat (limited to 'actionview/lib')
-rw-r--r--actionview/lib/action_view/cache_expiry.rb2
1 files changed, 2 insertions, 0 deletions
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