From 2fd6c3799dd04dcae0948acd25c40dded1459756 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Wed, 22 May 2019 16:42:34 -0700 Subject: Fix EventedFileUpdateChecker through a symlink On MacOS, Dir.tmpdir gives me a folder inside "/var/folders/". However, /var is a symlink to /private/var. Previously, the nonexistent directory test would fail because it was initialized with /var/folders/... but the filenames from listen would be the realpaths. This commit normalizes the dirs by calling realpath on them if they exist. This is done on boot!, so it will work with newly directories through the symlink. --- activesupport/lib/active_support/evented_file_update_checker.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/evented_file_update_checker.rb b/activesupport/lib/active_support/evented_file_update_checker.rb index 3893b0de0e..15b84537cc 100644 --- a/activesupport/lib/active_support/evented_file_update_checker.rb +++ b/activesupport/lib/active_support/evented_file_update_checker.rb @@ -107,6 +107,7 @@ module ActiveSupport private def boot! + normalize_dirs! Listen.to(*@dtw, &method(:changed)).start end @@ -114,6 +115,12 @@ module ActiveSupport Listen.stop end + def normalize_dirs! + @dirs.transform_keys! do |dir| + dir.exist? ? dir.realpath : dir + end + end + def changed(modified, added, removed) unless updated? @updated.make_true if (modified + added + removed).any? { |f| watching?(f) } -- cgit v1.2.3