diff options
author | Yuji Yaginuma <yuuji.yaginuma@gmail.com> | 2018-12-21 16:58:47 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-21 16:58:47 +0900 |
commit | 1d21ad9c46b833d463cb1bb9fb593c6106f0e44a (patch) | |
tree | f30196077569784c8f05038425da6e86def7a094 /activesupport/lib/active_support | |
parent | 5d905abbe77295e65c88b50940af4bfb99a48482 (diff) | |
parent | caa3cc8868206f8109e0d633efb09d31e94ef635 (diff) | |
download | rails-1d21ad9c46b833d463cb1bb9fb593c6106f0e44a.tar.gz rails-1d21ad9c46b833d463cb1bb9fb593c6106f0e44a.tar.bz2 rails-1d21ad9c46b833d463cb1bb9fb593c6106f0e44a.zip |
Merge pull request #33822 from y-yagi/do_not_check_parents_dor_directories
Do no watch parent directory of `dirs`
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/evented_file_update_checker.rb | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/evented_file_update_checker.rb b/activesupport/lib/active_support/evented_file_update_checker.rb index 97e982eb05..1ef8584c52 100644 --- a/activesupport/lib/active_support/evented_file_update_checker.rb +++ b/activesupport/lib/active_support/evented_file_update_checker.rb @@ -52,7 +52,10 @@ module ActiveSupport @pid = Process.pid @boot_mutex = Mutex.new - if (@dtw = directories_to_watch).any? + dtw = directories_to_watch + @dtw, @missing = dtw.partition(&:exist?) + + if @dtw.any? # Loading listen triggers warnings. These are originated by a legit # usage of attr_* macros for private attributes, but adds a lot of noise # to our test suite. Thus, we lazy load it and disable warnings locally. @@ -75,6 +78,19 @@ module ActiveSupport @updated.make_true end end + + if @missing.any?(&:exist?) + @boot_mutex.synchronize do + appeared, @missing = @missing.partition(&:exist?) + shutdown! + + @dtw += appeared + boot! + + @updated.make_true + end + end + @updated.true? end @@ -96,6 +112,10 @@ module ActiveSupport Listen.to(*@dtw, &method(:changed)).start end + def shutdown! + Listen.stop + end + def changed(modified, added, removed) unless updated? @updated.make_true if (modified + added + removed).any? { |f| watching?(f) } @@ -123,7 +143,7 @@ module ActiveSupport end def directories_to_watch - dtw = (@files + @dirs.keys).map { |f| @ph.existing_parent(f) } + dtw = @files.map(&:dirname) + @dirs.keys dtw.compact! dtw.uniq! |