Skip to content

Commit

Permalink
prepare monkeypatch to modify FileSetActor#create_content
Browse files Browse the repository at this point in the history
  • Loading branch information
aploshay committed Feb 9, 2024
1 parent 4175819 commit 2144c8b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/extensions/extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ def attribute_will_change!(attr)
Hyrax::CurationConcern.actor_factory.swap Hyrax::Actors::CreateWithRemoteFilesActor, ESSI::Actors::CreateWithRemoteFilesOrderedMembersStructureActor
Hyrax::CurationConcern.actor_factory.swap Hyrax::Actors::CreateWithFilesActor, Hyrax::Actors::CreateWithFilesOrderedMembersActor
Hyrax::Actors::BaseActor.prepend Extensions::Hyrax::Actors::BaseActor::UndoAttributeArrayWrap
Hyrax::Actors::FileSetActor.prepend Extensions::Hyrax::Actors::FileSetActor::CreateContent


# .jp2 conversion settings
Hydra::Derivatives.kdu_compress_path = ESSI.config.dig(:essi, :kdu_compress_path)
Expand Down
35 changes: 35 additions & 0 deletions lib/extensions/hyrax/actors/file_set_actor/create_content.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# unmodified from hyrax
module Extensions
module Hyrax
module Actors
module FileSetActor
module CreateContent
# Spawns asynchronous IngestJob unless ingesting from URL
# Called from FileSetsController, AttachFilesToWorkJob, IngestLocalFileJob, ImportUrlJob
# @param [Hyrax::UploadedFile, File] file the file uploaded by the user
# @param [Symbol, #to_s] relation
# @return [IngestJob, FalseClass] false on failure, otherwise the queued job
def create_content(file, relation = :original_file, from_url: false)
# If the file set doesn't have a title or label assigned, set a default.
file_set.label ||= label_for(file)
file_set.title = [file_set.label] if file_set.title.blank?
return false unless file_set.save # Need to save to get an id
if from_url
# If ingesting from URL, don't spawn an IngestJob; instead
# reach into the FileActor and run the ingest with the file instance in
# hand. Do this because we don't have the underlying UploadedFile instance
file_actor = build_file_actor(relation)
file_actor.ingest_file(wrapper!(file: file, relation: relation))
# Copy visibility and permissions from parent (work) to
# FileSets even if they come in from BrowseEverything
VisibilityCopyJob.perform_later(file_set.parent)
InheritPermissionsJob.perform_later(file_set.parent)
else
IngestJob.perform_later(wrapper!(file: file, relation: relation))
end
end
end
end
end
end
end

0 comments on commit 2144c8b

Please sign in to comment.