diff --git a/apps/dashboard/app/models/files.rb b/apps/dashboard/app/models/files.rb index f513bc50c0..cae49265df 100644 --- a/apps/dashboard/app/models/files.rb +++ b/apps/dashboard/app/models/files.rb @@ -21,6 +21,14 @@ def self.files_to_zip(path) def ls(dirpath) Pathname.new(dirpath).each_child.map do |path| Files.stat(path) + end.select do |stats| + valid_encoding = stats[:name].to_s.valid_encoding? + + unless valid_encoding + Rails.logger.warn("Not showing file '#{stats[:name]}' because it is not a UTF-8 filename.") + end + + valid_encoding end.sort_by { |p| p[:directory] ? 0 : 1 } end