aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2012-07-02 23:56:13 +0200
committerXavier Noria <fxn@hashref.com>2012-07-02 23:56:13 +0200
commit65dc45ea2d0da224494b2dee800853cc29cea1f0 (patch)
tree6de6da5a6ef7dcf26a49f21f681060e63d0e0c42 /activesupport
parentb8a5bb2c5e798ff855182aa003e7fdc52d44bf57 (diff)
downloadrails-65dc45ea2d0da224494b2dee800853cc29cea1f0.tar.gz
rails-65dc45ea2d0da224494b2dee800853cc29cea1f0.tar.bz2
rails-65dc45ea2d0da224494b2dee800853cc29cea1f0.zip
explains why the file update checker ignores mtimes in the future, plus a little refactor for the same price
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/file_update_checker.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/file_update_checker.rb b/activesupport/lib/active_support/file_update_checker.rb
index 9decbaef32..1cc852a3e6 100644
--- a/activesupport/lib/active_support/file_update_checker.rb
+++ b/activesupport/lib/active_support/file_update_checker.rb
@@ -101,9 +101,19 @@ module ActiveSupport
end
def updated_at(paths)
+ @updated_at || max_mtime(paths) || Time.at(0)
+ end
+
+ # This method returns the maximum mtime of the files in +paths+, or +nil+
+ # if the array is empty.
+ #
+ # Files with a mtime in the future are ignored. Such abnormal situation
+ # can happen for example if the user changes the clock by hand. It is
+ # healthy to consider this edge case because with mtimes in the future
+ # reloading is not triggered.
+ def max_mtime(paths)
time_now = Time.now
- @updated_at || paths.map { |path| File.mtime(path) }.
- reject { |time| time > time_now }.max || Time.at(0)
+ paths.map {|path| File.mtime(path)}.reject {|mtime| time_now < mtime}.max
end
def compile_glob(hash)