diff --git a/lib/jekyll/cleaner.rb b/lib/jekyll/cleaner.rb index a8bbf24e..9146e7de 100644 --- a/lib/jekyll/cleaner.rb +++ b/lib/jekyll/cleaner.rb @@ -36,18 +36,13 @@ module Jekyll # # Returns a Set with the file paths def existing_files - return Set.new unless Dir.exist?(site.in_dest_dir) - files = Set.new regex = keep_file_regex dirs = keep_dirs - Dir.chdir(site.in_dest_dir) do - Dir.glob("**/*", File::FNM_DOTMATCH).each do |f| - file = File.join(site.in_dest_dir, f) - next if file =~ HIDDEN_FILE_REGEX || file =~ regex || dirs.include?(file) - files << file - end + Utils.safe_glob(site.in_dest_dir, "**/*", File::FNM_DOTMATCH).each do |file| + next if file =~ HIDDEN_FILE_REGEX || file =~ regex || dirs.include?(file) + files << file end files diff --git a/lib/jekyll/collection.rb b/lib/jekyll/collection.rb index 4d4b9bd0..e4725718 100644 --- a/lib/jekyll/collection.rb +++ b/lib/jekyll/collection.rb @@ -74,11 +74,8 @@ module Jekyll def entries return Array.new unless exists? @entries ||= - Dir.chdir(collection_dir) do - Dir.glob("**/*.*").map do |f| - entry = collection_dir(f) - entry["#{collection_dir}/"] = ''; entry - end + Utils.safe_glob(collection_dir, "**/*.*").map do |entry| + entry["#{collection_dir}/"] = ''; entry end end