Skip to content

Commit

Permalink
find file content using dynamic storage adapters in FileMetadata
Browse files Browse the repository at this point in the history
`FileMetadata#file` should work for all storage adapters. it previously assumed
that the storage adapter would be the configured one, but if a `FileMetadata`
exists with a `file_identifier` in another URI scheme, it should resolve rather
than error.

rescue the AdapterNotFound case because the prior behavior was to always
return a file, even if `file_identifier` is `nil`. for compatibility reasons, i
don't want to change that at least until a sharper interface with error handling
can be dreamed up.
  • Loading branch information
tamsin johnson authored and tamsin johnson committed Jun 16, 2022
1 parent 76dc5af commit f6ef1e3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/models/hyrax/file_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,14 @@ def content
end

def file
Hyrax.storage_adapter.find_by(id: file_identifier)
adapter =
begin
Valkyrie::StorageAdapter.adapter_for(id: file_identifier)
rescue Valkyrie::StorageAdapter::AdapterNotFoundError => _err
Hyrax.storage_adapter
end

adapter.find_by(id: file_identifier)
end
end
end

0 comments on commit f6ef1e3

Please sign in to comment.