Skip to content

Commit

Permalink
Merge branch 'main' into bootstrap_card_fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
orangewolf committed Dec 18, 2024
2 parents 3603820 + 46bb6d2 commit e122df7
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 16 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
5 changes: 4 additions & 1 deletion app/factories/bulkrax/object_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions app/models/concerns/bulkrax/export_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions app/parsers/bulkrax/csv_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,18 @@ 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')
FileUtils.mkdir_p(path) unless File.exist? path
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
Expand Down
2 changes: 1 addition & 1 deletion app/parsers/bulkrax/parser_export_record_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion bulkrax.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion lib/bulkrax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e122df7

Please sign in to comment.