Skip reactor on test env

Update last_event sooner
Use ctime instead of mtime (Rails 3.1 assets pipeline issue)
This commit is contained in:
Thibaud Guillaume-Gentil 2011-09-02 16:22:01 +02:00
parent c4ddb29fc6
commit 47be15125b

View File

@ -41,6 +41,7 @@ module Guard
end end
def start_reactor def start_reactor
return if ENV["GUARD_ENV"] == 'test'
Thread.new do Thread.new do
loop do loop do
if @changed_files != [] && !@locked if @changed_files != [] && !@locked
@ -82,8 +83,9 @@ module Guard
end end
def modified_files(dirs, options = {}) def modified_files(dirs, options = {})
files = potentially_modified_files(dirs, options).select { |path| file_modified?(path) } last_event = @last_event.dup
update_last_event update_last_event
files = potentially_modified_files(dirs, options).select { |path| file_modified?(path, last_event) }
relativize_paths(files) relativize_paths(files)
end end
@ -140,10 +142,10 @@ module Guard
# Depending on the filesystem, mtime is probably only precise to the second, so round # Depending on the filesystem, mtime is probably only precise to the second, so round
# both values down to the second for the comparison. # both values down to the second for the comparison.
def file_modified?(path) def file_modified?(path, last_event)
if File.mtime(path).to_i == @last_event.to_i if File.ctime(path).to_i == last_event.to_i
file_content_modified?(path, sha1_checksum(path)) 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)) set_sha1_checksums_hash(path, sha1_checksum(path))
true true
end end