The file watcher knows which files exist, so don't use slow File.exists?

Possible solution for #903
This commit is contained in:
Thomas Reynolds 2013-05-22 17:37:43 -07:00
parent fc37ef9b99
commit c9d151ba66
3 changed files with 12 additions and 5 deletions

View file

@ -56,6 +56,7 @@ module Middleman
class API
attr_reader :app
attr_reader :known_paths
delegate :logger, :to => :app
# Initialize api and internal path cache
@ -142,6 +143,12 @@ module Middleman
reload_path(path, true)
end
def exists?(path)
p = Pathname(path)
p = p.relative_path_from(Pathname(@app.root)) if !p.relative?
@known_paths.include?(p)
end
protected
# Whether this path is ignored
# @param [Pathname] path