From 696aea211ac344c81382258c7dedcc4a5b15014b Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Mon, 14 Apr 2014 22:56:23 -0400 Subject: [PATCH] Don't gather any entries if the collection directory doesn't exist --- lib/jekyll/collection.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/jekyll/collection.rb b/lib/jekyll/collection.rb index 4bee732a..d2d1ae93 100644 --- a/lib/jekyll/collection.rb +++ b/lib/jekyll/collection.rb @@ -38,6 +38,7 @@ module Jekyll # Returns an Array of file paths to the documents in this collection # relative to the collection's directory def entries + return Array.new unless exists? Dir.glob(File.join(directory, "**", "*.*")).map do |entry| entry[File.join(directory, "")] = ''; entry end @@ -69,6 +70,16 @@ module Jekyll Jekyll.sanitized_path(site.source, relative_directory) end + # Checks whether the directory "exists" for this collection. + # The directory must exist on the filesystem and must not be a symlink + # if in safe mode. + # + # Returns false if the directory doesn't exist or if it's a symlink + # and we're in safe mode. + def exists? + File.directory?(directory) && !(File.symlink?(directory) && site.safe) + end + # The entry filter for this collection. # Creates an instance of Jekyll::EntryFilter. #