Sha256: 315226ad7fe82686fb353139d81ff3e5b9dc36047fbd9358ce0107c6315025dc

Contents?: true

Size: 1.12 KB

Versions: 27

Compression:

Stored size: 1.12 KB

Contents

class CharacterizeJob < Hyrax::ApplicationJob
  queue_as Hyrax.config.ingest_queue_name

  # Characterizes the file at 'filepath' if available, otherwise, pulls a copy from the repository
  # and runs characterization on that file.
  # @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)
    raise "#{file_set.class.characterization_proxy} was not found for FileSet #{file_set.id}" unless file_set.characterization_proxy?
    filepath = Hyrax::WorkingDirectory.find_or_retrieve(file_id, file_set.id) unless filepath && File.exist?(filepath)
    Hydra::Works::CharacterizationService.run(file_set.characterization_proxy, filepath)
    Rails.logger.debug "Ran characterization on #{file_set.characterization_proxy.id} (#{file_set.characterization_proxy.mime_type})"
    file_set.characterization_proxy.save!
    file_set.update_index
    file_set.parent&.in_collections&.each(&:update_index)
    CreateDerivativesJob.perform_later(file_set, file_id, filepath)
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/jobs/characterize_job.rb
hyrax-2.9.5 app/jobs/characterize_job.rb
hyrax-2.9.4 app/jobs/characterize_job.rb
hyrax-2.9.3 app/jobs/characterize_job.rb
hyrax-2.9.2 app/jobs/characterize_job.rb
hyrax-2.9.1 app/jobs/characterize_job.rb
hyrax-2.9.0 app/jobs/characterize_job.rb
hyrax-2.8.0 app/jobs/characterize_job.rb
hyrax-2.7.2 app/jobs/characterize_job.rb
hyrax-2.7.1 app/jobs/characterize_job.rb
hyrax-2.7.0 app/jobs/characterize_job.rb
hyrax-2.6.0 app/jobs/characterize_job.rb
hyrax-2.5.1 app/jobs/characterize_job.rb
hyrax-2.5.0 app/jobs/characterize_job.rb
hyrax-3.0.0.pre.beta2 app/jobs/characterize_job.rb
hyrax-2.4.1 app/jobs/characterize_job.rb
hyrax-3.0.0.pre.beta1 app/jobs/characterize_job.rb
hyrax-2.4.0 app/jobs/characterize_job.rb
hyrax-2.3.3 app/jobs/characterize_job.rb
hyrax-2.3.2 app/jobs/characterize_job.rb