Skip to content
Snippets Groups Projects
Commit 327e6c20 authored by Anusha Ranganathan's avatar Anusha Ranganathan
Browse files

Removed restriction of hidden files upload

parent 9120e3d1
Branches
Tags
1 merge request!307Removed restriction of hidden files upload
......@@ -136,4 +136,9 @@ module HyraxHelper
filtered_data.to_json
end
def restricted_file_names?(file_name)
parsed_file = YAML.load_file(Rails.root.join('config', 'restricted_files.yml'))
parsed_file['restricted_file_names'].map(&:downcase).include?(file_name.downcase)
end
end
......@@ -6,6 +6,7 @@ module Hyrax
# Eventually these files get attached to {FileSet}s and pushed into Fedora.
class UploadedFile < ActiveRecord::Base
self.table_name = 'uploaded_files'
include HyraxHelper
mount_uploader :file, UploadedFileUploader
alias uploader file
has_many :job_io_wrappers,
......@@ -51,8 +52,8 @@ module Hyrax
parsed_file = YAML.load_file(Rails.root.join('config', 'restricted_files.yml'))
file_name = file.file.original_filename
if parsed_file['restricted_file_names'].include?(file_name.gsub(/[\s_\-]/, '').downcase) || file_name.start_with?('.')
if restricted_file_names?(file_name)
errors.add(:base, "This file name is restricted.")
end
end
......
......@@ -2,6 +2,7 @@
class PrepareCsvFromCrcFolder
attr_reader :parser, :csv_file_path
include HyraxHelper
def initialize(parser)
@parser = parser
......@@ -558,7 +559,7 @@ class PrepareCsvFromCrcFolder
end
def create_file_sets_for_work(folder_path, csv, meta_info)
Dir.glob("#{folder_path}/*").reject { |item| Pathname(item).directory? || item.include?('MetaApp2_SFB1280.exe') || item.include?('meta.json') }.each_with_index do |file_path, index|
Dir.glob("#{folder_path}/{,.[^.],..?}*").reject { |item| Pathname(item).directory? || restricted_file_names?(item.split('/')[-1]) }.each_with_index do |file_path, index|
for_complex_type = meta_info[:crc_work_type] == 'experiment' ? "CrcDataset" : meta_info[:crc_work_type]
csv << ['FileSet', '', '', file_path, SecureRandom.uuid, meta_info[:parent_work_source_identifier] || meta_info[:source_identifier], meta_info[:source_identifier], for_complex_type, file_path.split('/')[-1]]
end
......
......@@ -2,4 +2,6 @@ restricted_file_names:
- metadata.json
- meta.json
- .DS_Store
- desktop.ini
\ No newline at end of file
- desktop.ini
- .gitignore
- MetaApp2_SFB1280.exe
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment