Skip to content

Commit

Permalink
Merge pull request #290 from scientist-softserv/fix-triggering-child-…
Browse files Browse the repository at this point in the history
…works-job

Create Child Works based on PDF fileset's file
  • Loading branch information
laritakr authored Nov 20, 2023
2 parents e492798 + d99da3c commit e42cfd2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion app/actors/iiif_print/actors/file_set_actor_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# frozen_string_literal: true

# override to add PDF splitting for file sets and remove splitting upon fileset delete

# Depending on whether we have an uploaded file or a remote url, the sequence of calling
# attach_to_work and create_content will switch.
module IiifPrint
module Actors
module FileSetActorDecorator
Expand All @@ -9,7 +12,9 @@ def create_content(file, relation = :original_file, from_url: false)
super

if from_url
args = { file_set: file_set, file: file, import_url: file_set.import_url, user: @user }
# in this case, the file that came in is a temp file, and we need to use the actual file.
# the file was attached to the file_set in Hyrax::ImportUrlJob so we can just access it.
args = { file_set: file_set, file: file_set.files.first, import_url: file_set.import_url, user: @user }
returned_value = service.conditionally_enqueue(**args)
Rails.logger.info("Result of #{returned_value} for conditional enqueueing of #{args.inspect}")
true
Expand All @@ -24,6 +29,10 @@ def attach_to_work(work, file_set_params = {})
# Locks to ensure that only one process is operating on the list at a time.
super

# when we are importing a remote_url, this method is called before the file is attached.
# We want to short-circuit the process and prevent unnecessarily confusing logging.
return unless @file

args = { file_set: file_set, work: work, file: @file, user: @user }
returned_value = service.conditionally_enqueue(**args)
Rails.logger.info("Result of #{returned_value} for conditional enqueueing of #{args.inspect}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def self.conditionally_enqueue(file_set:, file:, user:, import_url: nil, work: n
return :no_split_for_parent unless iiif_print_split?(work: work)
return :no_pdfs_for_import_url if import_url && !pdfs?(paths: [import_url])
file_locations = if import_url
[file.path]
[Hyrax::WorkingDirectory.find_or_retrieve(file.id, file_set.id)]
else
pdf_paths(files: [file.try(:id)&.to_s].compact)
end
Expand Down

0 comments on commit e42cfd2

Please sign in to comment.