Sha256: 29d480bd4b5eae4095cb44343fb4330948a4cef690dacea5e92ce92e64e55ddc

Contents?: true

Size: 985 Bytes

Versions: 14

Compression:

Stored size: 985 Bytes

Contents

# frozen_string_literal: true
class CreateDerivativesJob < Hyrax::ApplicationJob
  queue_as Hyrax.config.ingest_queue_name

  # @param [FileSet] file_set
  # @param [String] file_id identifier for a Hydra::PCDM::File
  # @param [String, NilClass] filepath the cached file within the Hyrax.config.working_path
  def perform(file_set, file_id, filepath = nil)
    return if file_set.video? && !Hyrax.config.enable_ffmpeg
    filename = Hyrax::WorkingDirectory.find_or_retrieve(file_id, file_set.id, filepath)

    file_set.create_derivatives(filename)

    # Reload from Fedora and reindex for thumbnail and extracted text
    file_set.reload
    file_set.update_index
    file_set.parent.update_index if parent_needs_reindex?(file_set)
  end

  # If this file_set is the thumbnail for the parent work,
  # then the parent also needs to be reindexed.
  def parent_needs_reindex?(file_set)
    return false unless file_set.parent
    file_set.parent.thumbnail_id == file_set.id
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
hyrax-3.6.0 app/jobs/create_derivatives_job.rb
hyrax-3.5.0 app/jobs/create_derivatives_job.rb
hyrax-3.4.2 app/jobs/create_derivatives_job.rb
hyrax-3.4.1 app/jobs/create_derivatives_job.rb
hyrax-3.4.0 app/jobs/create_derivatives_job.rb
hyrax-3.3.0 app/jobs/create_derivatives_job.rb
hyrax-3.2.0 app/jobs/create_derivatives_job.rb
hyrax-3.1.0 app/jobs/create_derivatives_job.rb
hyrax-3.0.2 app/jobs/create_derivatives_job.rb
hyrax-3.0.1 app/jobs/create_derivatives_job.rb
hyrax-3.0.0 app/jobs/create_derivatives_job.rb
hyrax-3.0.0.pre.rc4 app/jobs/create_derivatives_job.rb
hyrax-3.0.0.pre.rc3 app/jobs/create_derivatives_job.rb
hyrax-3.0.0.pre.rc2 app/jobs/create_derivatives_job.rb