aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2016-04-12 10:56:42 -0700
committerXavier Noria <fxn@hashref.com>2016-04-12 10:56:42 -0700
commitb271eda7031aa5cdd2fd4db2ae5fdbee5efd5cb6 (patch)
tree0e7a7cbddad1954f72fa83febcd0ae411f705417 /activesupport/lib/active_support
parent714ab8cb5976587470c8487720094c1efb2ba9a2 (diff)
parentf05704fc1aec5f859c78a75d26dc694c51a729af (diff)
downloadrails-b271eda7031aa5cdd2fd4db2ae5fdbee5efd5cb6.tar.gz
rails-b271eda7031aa5cdd2fd4db2ae5fdbee5efd5cb6.tar.bz2
rails-b271eda7031aa5cdd2fd4db2ae5fdbee5efd5cb6.zip
Merge pull request #24523 from BlakeMesdag/as-max_time-fix-edges
Handle max_time edge cases for epoch times and add test
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/file_update_checker.rb18
1 files changed, 11 insertions, 7 deletions
diff --git a/activesupport/lib/active_support/file_update_checker.rb b/activesupport/lib/active_support/file_update_checker.rb
index 4f0a2dedc5..fa0b1a4bcf 100644
--- a/activesupport/lib/active_support/file_update_checker.rb
+++ b/activesupport/lib/active_support/file_update_checker.rb
@@ -112,23 +112,27 @@ module ActiveSupport
# reloading is not triggered.
def max_mtime(paths)
time_now = Time.now
- time_at_zero = Time.at(0)
- max_time = time_at_zero
+ max_mtime = nil
paths.each do |path|
- time = File.mtime(path)
+ mtime = File.mtime(path)
+
+ # Prevent dates in the future being considered
+ # Equivalent ruby:
+ # time.now < mtime
+ next if time_now.compare_without_coercion(mtime) < 0
# This avoids ActiveSupport::CoreExt::Time#time_with_coercion
# which is super slow when comparing two Time objects
#
# Equivalent Ruby:
- # time < time_now && time > max_time
- if time.compare_without_coercion(time_now) < 0 && time.compare_without_coercion(max_time) > 0
- max_time = time
+ # max_mtime.nil? || max_mtime < mtime
+ if max_mtime.nil? || max_mtime.compare_without_coercion(mtime) < 0
+ max_mtime = mtime
end
end
- max_time.object_id == time_at_zero.object_id ? nil : max_time
+ max_mtime
end
def compile_glob(hash)