Skip to content

Commit

Permalink
Revert external storage merge for 1.5.5 release
Browse files Browse the repository at this point in the history
  • Loading branch information
dlpierce committed Jul 8, 2024
1 parent ed1c62f commit 057ee3f
Show file tree
Hide file tree
Showing 19 changed files with 110 additions and 956 deletions.
34 changes: 5 additions & 29 deletions app/actors/hyrax/actors/file_actor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,10 @@ def ingest_file(io)
delete_characterization_path = 'include_parent_dir'
end

if use_external_storage?
add_file_to_external_storage(io)
else
Hydra::Works::AddFileToFileSet.call(file_set,
io,
relation,
versioning: false)
end

Hydra::Works::AddFileToFileSet.call(file_set,
io,
relation,
versioning: false)
end
if store_masters?
url = master_url_for_file_set(file_set) || master_file_service_url
Expand Down Expand Up @@ -88,28 +83,9 @@ def self.store_files?
ESSI.config.dig :essi, :store_original_files
end

def use_external_storage?
ESSI.config.dig :essi, :store_in_external_storage
end

private

def add_file_to_external_storage(io)
original_name = Hydra::Works::DetermineOriginalName.call(io)
ext = File.extname(original_name)
mime_type = Hydra::Works::DetermineMimeType.call(io, original_name)
id = "#{file_set.id}-#{relation}#{ext}"
file = io.send :file # This is a public method in later versions of Hyrax
response = ESSI.external_storage.put(id, file,
content_type: mime_type,
params: { metadata: { original_name: original_name }})
content_location = ESSI.external_storage.id_to_s3_uri(id)
Hyrax.logger.debug { "Added #{id} to external storage at #{content_location}" }
file_set.content_location = content_location
Hydra::Works::AddExternalFileToFileSet.call(file_set, ::RDF::URI(content_location), relation, versioning: false)
end

# @return [Hydra::PCDM::File] the file referenced by relation
# @return [Hydra::PCDM::File] the file referenced by relation
def related_file
file_set.public_send(relation) || raise("No #{relation} returned for FileSet #{file_set.id}")
end
Expand Down
6 changes: 2 additions & 4 deletions app/helpers/catalog_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@ def thumbnail_url document
representative_document = ::SolrDocument.find(document.thumbnail_id)
end

thumbnail_file_id = representative_document&.content_location
thumbnail_file_id ||= representative_document.original_file_id
thumbnail_file_id = representative_document.original_file_id
if thumbnail_file_id
Hyrax.config.iiif_image_url_builder.call(thumbnail_file_id, nil, '250,')
else
raise 'thumbnail_file_id is nil'
end

rescue StandardError => e
Hyrax.logger.warn { "Failed to resolve thumbnail url for #{document&.id}: #{e.message}" }
rescue
image_path 'default.png'
end
end
3 changes: 0 additions & 3 deletions app/indexers/essi/file_set_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ def generate_solr_document
end
solr_doc['word_boundary_tsi'] = IiifPrint::TextExtraction::AltoReader.new(object.extracted_text.content).json if object.extracted_text.present?
solr_doc[Solrizer.solr_name('iiif_index_strategy')] = IndexerHelper.iiif_index_strategy

# Records storage location of the file. e.g. 's3' if in external storage
solr_doc['content_location_ssi'] = object.content_location if object.content_location.present?
end
end
end
Expand Down
4 changes: 0 additions & 4 deletions app/models/concerns/essi/file_set_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ module FileSetMetadata
property :viewing_hint, predicate: ::RDF::Vocab::IIIF.viewingHint, multiple: false do |index|
index.as :stored_searchable
end

property :content_location, predicate: ::RDF::Vocab::IANA.service, multiple: false do |index|
index.as :stored_searchable
end
end
end
end
1 change: 0 additions & 1 deletion app/models/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class SolrDocument
attribute :ocr_searchable, Solr::String, solr_name('ocr_searchable', Solrizer::Descriptor.new(:boolean, :stored, :indexed))
# @todo remove after upgrade to Hyrax 3.x
attribute :original_file_id, Solr::String, solr_name('original_file_id', :stored_sortable)
attribute :content_location, Solr::String, solr_name('content_location', :stored_sortable)
attribute :pdf_downloadable, Solr::String, solr_name('pdf_downloadable', Solrizer::Descriptor.new(:boolean, :stored, :indexed))
attribute :file_set_ids, Solr::Array, solr_name('file_set_ids', :symbol)
attribute :extracted_text, Solr::String, 'all_text_tsimv'
Expand Down
10 changes: 0 additions & 10 deletions app/presenters/hyrax/displays_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,6 @@ def lookup_original_file_id
result
end

private

def iiif_endpoint(file_id)
return unless Hyrax.config.iiif_image_server?
IIIFManifest::IIIFEndpoint.new(
Hyrax.config.iiif_info_url_builder.call(file_id, request.base_url),
profile: Hyrax.config.iiif_image_compliance_level_uri
)
end

# @todo remove after upgrade to Hyrax 3.x
# cherry-picked from Hyrax 3.x VersioningService
# @param [ActiveFedora::File | Hyrax::FileMetadata] content
Expand Down
109 changes: 0 additions & 109 deletions app/services/essi/external_storage_service.rb

This file was deleted.

3 changes: 1 addition & 2 deletions app/services/iiif_thumbnail_path_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ class << self
# @param [FileSet] thumbnail the object that is the thumbnail
def thumbnail_path(thumbnail)
return unless thumbnail.original_file
id = thumbnail.content_location || thumbnail.original_file.id
Hyrax.config.iiif_image_url_builder.call(id, nil, '250,')
Hyrax.config.iiif_image_url_builder.call(thumbnail.original_file.id, nil, '250,')
# Hyrax::Engine.routes.url_helpers.download_path(thumbnail.id,
# file: 'thumbnail')
end
Expand Down
Loading

0 comments on commit 057ee3f

Please sign in to comment.