diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 06aed9f9..a2d2088f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,15 +15,15 @@ jobs: - uses: actions/checkout@v2 - name: Cache - uses: actions/cache@v2.1.3 + uses: actions/cache@v4.2.0 with: path: vendor/bundle - key: 2.7.2 + key: 3.2 - name: Setup Ruby - uses: ruby/setup-ruby@v1.159.0 + uses: ruby/setup-ruby@v1.204.0 with: - ruby-version: 2.7.2 + ruby-version: 3.2 - name: Install dependencies run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 95bb60af..5ed6c1f5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,13 +18,13 @@ jobs: - uses: actions/checkout@v2 - name: Cache - uses: actions/cache@v2.1.3 + uses: actions/cache@v4.2.0 with: path: vendor/bundle key: ${{ matrix.ruby }} - name: Setup Ruby - uses: ruby/setup-ruby@v1.159.0 + uses: ruby/setup-ruby@v1.204.0 with: ruby-version: ${{ matrix.ruby }} diff --git a/app/factories/bulkrax/object_factory.rb b/app/factories/bulkrax/object_factory.rb index fa7430d7..5872fe12 100644 --- a/app/factories/bulkrax/object_factory.rb +++ b/app/factories/bulkrax/object_factory.rb @@ -165,7 +165,10 @@ def find_by_id end def delete(_user) - find&.delete(eradicate: true) + obj = find + return false unless obj + + obj.delete(eradicate: true) end private diff --git a/app/models/concerns/bulkrax/export_behavior.rb b/app/models/concerns/bulkrax/export_behavior.rb index 4cfa8513..23a98f50 100644 --- a/app/models/concerns/bulkrax/export_behavior.rb +++ b/app/models/concerns/bulkrax/export_behavior.rb @@ -26,11 +26,15 @@ def hyrax_record # Prepend the file_set id to ensure a unique filename and also one that is not longer than 255 characters def filename(file_set) - # NOTE: Will this work with Valkyrie? return if file_set.original_file.blank? - fn = file_set.original_file.file_name.first - mime = ::Marcel::MimeType.for(file_set.original_file.mime_type) - ext_mime = ::Marcel::MimeType.for(file_set.original_file.file_name) + if file_set.original_file.respond_to?(:original_filename) # valkyrie + fn = file_set.original_file.original_filename + mime = ::Marcel::MimeType.for(file_set.original_file.file.io) + else # original non valkyrie version + fn = file_set.original_file.file_name.first + mime = ::Marcel::MimeType.for(declared_type: file_set.original_file.mime_type) + end + ext_mime = ::Marcel::MimeType.for(name: fn) if fn.include?(file_set.id) || importerexporter.metadata_only? filename = "#{fn}.#{mime.to_sym}" filename = fn if mime.to_s == ext_mime.to_s diff --git a/app/parsers/bulkrax/csv_parser.rb b/app/parsers/bulkrax/csv_parser.rb index 03159ebb..de695a08 100644 --- a/app/parsers/bulkrax/csv_parser.rb +++ b/app/parsers/bulkrax/csv_parser.rb @@ -244,7 +244,10 @@ def store_files(identifier, folder_count) record = Bulkrax.object_factory.find(identifier) return unless record - file_sets = record.file_set? ? Array.wrap(record) : record.file_sets + file_sets = Array.wrap(record) if record.file_set? + if file_sets.nil? # for valkyrie + file_sets = record.respond_to?(:file_sets) ? record.file_sets : record.members&.select(&:file_set?) + end file_sets << record.thumbnail if exporter.include_thumbnails && record.thumbnail.present? && record.work? file_sets.each do |fs| path = File.join(exporter_export_path, folder_count, 'files') @@ -252,7 +255,7 @@ def store_files(identifier, folder_count) file = filename(fs) next if file.blank? || fs.original_file.blank? - io = open(fs.original_file.uri) + io = fs.original_file.respond_to?(:uri) ? open(fs.original_file.uri) : fs.original_file.file.io File.open(File.join(path, file), 'wb') do |f| f.write(io.read) f.close diff --git a/app/parsers/bulkrax/parser_export_record_set.rb b/app/parsers/bulkrax/parser_export_record_set.rb index 30262f94..f80d5c9b 100644 --- a/app/parsers/bulkrax/parser_export_record_set.rb +++ b/app/parsers/bulkrax/parser_export_record_set.rb @@ -173,7 +173,7 @@ def collections # @see https://github.com/samvera/hyrax/blob/64c0bbf0dc0d3e1b49f040b50ea70d177cc9d8f6/app/indexers/hyrax/work_indexer.rb#L15-L18 def file_sets @file_sets ||= ParserExportRecordSet.in_batches(candidate_file_set_ids) do |batch_of_ids| - fsq = "has_model_ssim:#{Bulkrax.file_model_internal_resource} AND id:(\"" + batch_of_ids.join('" OR "') + "\")" + fsq = "has_model_ssim:\"#{Bulkrax.file_model_internal_resource.demodulize}\" AND id:(\"" + batch_of_ids.join('" OR "') + "\")" fsq += extra_filters if extra_filters.present? Bulkrax.object_factory.query( fsq, diff --git a/bulkrax.gemspec b/bulkrax.gemspec index a894131a..9e26f3fc 100644 --- a/bulkrax.gemspec +++ b/bulkrax.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |s| s.files = Dir["{app,config,db,lib}/**/*", "LICENSE", "Rakefile", "README.md"] s.add_dependency 'rails', '>= 5.1.6' - s.add_dependency 'bagit', '~> 0.4.6' + s.add_dependency 'bagit', '~> 0.6.0' s.add_dependency 'coderay' s.add_dependency 'denormalize_fields' s.add_dependency 'marcel' diff --git a/lib/bulkrax.rb b/lib/bulkrax.rb index f6af63ee..1fd9a95f 100644 --- a/lib/bulkrax.rb +++ b/lib/bulkrax.rb @@ -92,7 +92,7 @@ def factory_class_name_coercer end def collection_model_class - @collection_model_class ||= Collection + @collection_model_class ||= Collection if defined?(::Hyrax) end attr_writer :collection_model_class