提交 65dc45ea 编写于 作者: X Xavier Noria

explains why the file update checker ignores mtimes in the future, plus a...

explains why the file update checker ignores mtimes in the future, plus a little refactor for the same price
上级 b8a5bb2c
......@@ -101,9 +101,19 @@ def watched
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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册