Differentiate polling from find_new_files to remove double reads in build mode

This commit is contained in:
Thomas Reynolds 2016-01-20 12:20:27 -08:00
parent ffa662a917
commit 6d1c3562a7
4 changed files with 28 additions and 6 deletions

View file

@ -91,7 +91,7 @@ module Middleman
validator: (block_given? ? block : regex))
bump_count
find_new_files! if @running
poll_once! if @running
end
# Whether this path is ignored.
@ -219,13 +219,24 @@ module Middleman
.find { |d| d.exists?(path) }
end
# Manually poll all watchers for new content.
# Manually check for new files
#
# @return [void]
Contract ArrayOf[Pathname]
def find_new_files!
return [] unless @update_count != @last_update_count
@last_update_count = @update_count
watchers.reduce([]) { |sum, w| sum + w.find_new_files! }
end
# Manually poll all watchers for new content.
#
# @return [void]
Contract ArrayOf[Pathname]
def poll_once!
return [] unless @update_count != @last_update_count
@last_update_count = @update_count
watchers.reduce([]) { |sum, w| sum + w.poll_once! }
end