diff --git a/activesupport/lib/active_support/file_evented_update_checker.rb b/activesupport/lib/active_support/file_evented_update_checker.rb index 8f734ac4e4f231ade9b4246d6e0125d26846b342..51c8cf569070d9576504757459d168bb3ebda7f8 100644 --- a/activesupport/lib/active_support/file_evented_update_checker.rb +++ b/activesupport/lib/active_support/file_evented_update_checker.rb @@ -126,19 +126,8 @@ def longest_common_subpath(paths) # Returns the deepest existing ascendant, which could be the argument itself. def existing_parent(dir) - loop do - if dir.directory? - break dir - else - if dir.root? - # Edge case in which not even the root exists. For example, Windows - # paths could have a non-existing drive letter. Since the parent of - # root is root, we need to break to prevent an infinite loop. - break - else - dir = dir.parent - end - end + dir.ascend do |ascendant| + break ascendant if ascendant.directory? end end