Sha256: f610af5f2603044558884f9f422d8b3470bffafdc34338b34daf0efe0827c02f

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

class CharacterizeJob < ActiveJob::Base
  include CurationConcerns::Lockable

  queue_as CurationConcerns.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 CurationConcerns.config.working_path
  def perform(file_set, file_id, filepath = nil)
    filename = CurationConcerns::WorkingDirectory.find_or_retrieve(file_id, file_set.id, filepath)
    raise LoadError, "#{file_set.class.characterization_proxy} was not found" unless file_set.characterization_proxy?

    # Prevent other jobs from trying to modify the FileSet at the same time
    acquire_lock_for(file_set.id) do
      Hydra::Works::CharacterizationService.run(file_set.characterization_proxy, filename)
      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) if file_set.parent
    end

    CreateDerivativesJob.perform_later(file_set, file_id, filename)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
curation_concerns-1.7.8 app/jobs/characterize_job.rb
curation_concerns-1.7.7 app/jobs/characterize_job.rb
curation_concerns-2.0.0 app/jobs/characterize_job.rb
curation_concerns-2.0.0.rc2 app/jobs/characterize_job.rb