From 47be15125b2c2ac279ba5baa036bf99c0aa2b631 Mon Sep 17 00:00:00 2001 From: Thibaud Guillaume-Gentil Date: Fri, 2 Sep 2011 16:22:01 +0200 Subject: [PATCH] Skip reactor on test env Update last_event sooner Use ctime instead of mtime (Rails 3.1 assets pipeline issue) --- lib/guard/listener.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/guard/listener.rb b/lib/guard/listener.rb index b4d31a4..2a53b85 100644 --- a/lib/guard/listener.rb +++ b/lib/guard/listener.rb @@ -41,6 +41,7 @@ module Guard end def start_reactor + return if ENV["GUARD_ENV"] == 'test' Thread.new do loop do if @changed_files != [] && !@locked @@ -82,8 +83,9 @@ module Guard end def modified_files(dirs, options = {}) - files = potentially_modified_files(dirs, options).select { |path| file_modified?(path) } + last_event = @last_event.dup update_last_event + files = potentially_modified_files(dirs, options).select { |path| file_modified?(path, last_event) } relativize_paths(files) end @@ -140,10 +142,10 @@ module Guard # Depending on the filesystem, mtime is probably only precise to the second, so round # both values down to the second for the comparison. - def file_modified?(path) - if File.mtime(path).to_i == @last_event.to_i + def file_modified?(path, last_event) + if File.ctime(path).to_i == last_event.to_i file_content_modified?(path, sha1_checksum(path)) - elsif File.mtime(path).to_i > @last_event.to_i + elsif File.ctime(path).to_i > last_event.to_i set_sha1_checksums_hash(path, sha1_checksum(path)) true end