From b6d3873cb8bbfb49b9606616c40dbda1ad50f5f2 Mon Sep 17 00:00:00 2001 From: Rob Kaufman Date: Thu, 7 Nov 2024 16:56:49 -0800 Subject: [PATCH] valkyrie pdf queuing --- app/jobs/iiif_print/jobs/child_works_from_pdf_job.rb | 3 ++- .../child_work_creation_from_pdf_service.rb | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/jobs/iiif_print/jobs/child_works_from_pdf_job.rb b/app/jobs/iiif_print/jobs/child_works_from_pdf_job.rb index b5907b5b..a1d20aa1 100644 --- a/app/jobs/iiif_print/jobs/child_works_from_pdf_job.rb +++ b/app/jobs/iiif_print/jobs/child_works_from_pdf_job.rb @@ -33,7 +33,8 @@ def perform(id, pdf_paths, user, admin_set_id, *) # However, there seem to be cases where we still don't have the file when we get here, so to be sure, we # re-do the same command that was previously used to prepare the file path. If the file is already here, it # simply returns the path, but if not it will copy the file there, giving us one more chance to have what we need. - pdf_paths = [Hyrax::WorkingDirectory.find_or_retrieve(pdf_file_set.original_file.id, pdf_file_set.id, pdf_paths.first)] if pdf_file_set + redownload = pdf_file_set && pdf_file_set.is_a?(ActiveFedora::Base) + pdf_paths = [Hyrax::WorkingDirectory.find_or_retrieve(pdf_file_set.original_file.id, pdf_file_set.id, pdf_paths.first)] if redownload # handle each input pdf (when input is a file set, we will only have one). pdf_paths.each do |original_pdf_path| split_pdf(original_pdf_path, user, child_model, pdf_file_set) diff --git a/lib/iiif_print/split_pdfs/child_work_creation_from_pdf_service.rb b/lib/iiif_print/split_pdfs/child_work_creation_from_pdf_service.rb index 15117fc4..02d39ab5 100644 --- a/lib/iiif_print/split_pdfs/child_work_creation_from_pdf_service.rb +++ b/lib/iiif_print/split_pdfs/child_work_creation_from_pdf_service.rb @@ -36,8 +36,16 @@ def self.conditionally_enqueue(file_set:, file:, user:, import_url: nil, work: n end return :no_pdfs_to_split if file_locations.empty? - IiifPrint.conditionally_submit_split_for(work: work, file_set: file_set, locations: file_locations, user: user) - :enqueued + file_set_id = file_set.id.try(:id) || file_set.id + work_admin_set_id = work.admin_set_id.try(:id) || work.admin_set_id + job = work.try(:iiif_print_config)&.pdf_splitter_job&.perform_later( + file_set_id, + file_locations, + user, + work_admin_set_id, + 0 # A no longer used parameter; but we need to preserve the method signature (for now) + ) + job ? :enqueued : :pdf_job_failed_enqueue end # rubocop:enable Metrics/MethodLength