diff options
author | Blake Mesdag <blakemesdag@gmail.com> | 2016-04-12 12:07:56 -0400 |
---|---|---|
committer | Blake Mesdag <blakemesdag@gmail.com> | 2016-04-12 12:07:56 -0400 |
commit | b0bce0b8ce807e4d92a8a01fa0235727d709c21d (patch) | |
tree | 7fa833470131abb591e950f72f8e6ee8582583af /activesupport/lib/active_support/file_update_checker.rb | |
parent | d6769f4d106ee6f9a3bbad925098260bdac5f799 (diff) | |
download | rails-b0bce0b8ce807e4d92a8a01fa0235727d709c21d.tar.gz rails-b0bce0b8ce807e4d92a8a01fa0235727d709c21d.tar.bz2 rails-b0bce0b8ce807e4d92a8a01fa0235727d709c21d.zip |
Handle max_time edge cases for epoch times and add test
Diffstat (limited to 'activesupport/lib/active_support/file_update_checker.rb')
-rw-r--r-- | activesupport/lib/active_support/file_update_checker.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/file_update_checker.rb b/activesupport/lib/active_support/file_update_checker.rb index 4f0a2dedc5..d1eb410c85 100644 --- a/activesupport/lib/active_support/file_update_checker.rb +++ b/activesupport/lib/active_support/file_update_checker.rb @@ -111,13 +111,22 @@ module ActiveSupport # healthy to consider this edge case because with mtimes in the future # reloading is not triggered. def max_mtime(paths) + return nil if paths.empty? + time_now = Time.now - time_at_zero = Time.at(0) - max_time = time_at_zero + max_time = nil paths.each do |path| time = File.mtime(path) + if max_time.nil? + if time.compare_without_coercion(time_now) < 0 + max_time = time + end + + next + end + # This avoids ActiveSupport::CoreExt::Time#time_with_coercion # which is super slow when comparing two Time objects # @@ -128,7 +137,7 @@ module ActiveSupport end end - max_time.object_id == time_at_zero.object_id ? nil : max_time + max_time end def compile_glob(hash) |