Sha256: 587a14ab2f1965dbe8b2a2ec34a2b0720b197da970ce4fc1304b17e445331843

Contents?: true

Size: 1.5 KB

Versions: 10

Compression:

Stored size: 1.5 KB

Contents

class IngestFileJob < ActiveJob::Base
  queue_as Hyrax.config.ingest_queue_name

  # @param [FileSet] file_set
  # @param [String] filepath the cached file within the Hyrax.config.working_path
  # @param [User] user
  # @option opts [String] mime_type
  # @option opts [String] filename
  # @option opts [String] relation, ex. :original_file
  def perform(file_set, filepath, user, opts = {})
    relation = opts.fetch(:relation, :original_file).to_sym

    # Wrap in an IO decorator to attach passed-in options
    local_file = Hydra::Derivatives::IoDecorator.new(File.open(filepath, "rb"))
    local_file.mime_type = opts.fetch(:mime_type, nil)
    local_file.original_name = opts.fetch(:filename, File.basename(filepath))

    # Tell AddFileToFileSet service to skip versioning because versions will be minted by
    # VersionCommitter when necessary during save_characterize_and_record_committer.
    Hydra::Works::AddFileToFileSet.call(file_set,
                                        local_file,
                                        relation,
                                        versioning: false)

    # Persist changes to the file_set
    file_set.save!

    repository_file = file_set.send(relation)

    # Do post file ingest actions
    Hyrax::VersioningService.create(repository_file, user)

    # TODO: this is a problem, the file may not be available at this path on another machine.
    # It may be local, or it may be in s3
    CharacterizeJob.perform_later(file_set, repository_file.id, filepath)
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
hyrax-1.1.1 app/jobs/ingest_file_job.rb
hyrax-1.1.0 app/jobs/ingest_file_job.rb
hyrax-1.0.5 app/jobs/ingest_file_job.rb
hyrax-1.0.4 app/jobs/ingest_file_job.rb
hyrax-1.0.3 app/jobs/ingest_file_job.rb
hyrax-1.0.2 app/jobs/ingest_file_job.rb
hyrax-1.0.1 app/jobs/ingest_file_job.rb
hyrax-1.0.0.rc2 app/jobs/ingest_file_job.rb
hyrax-1.0.0.rc1 app/jobs/ingest_file_job.rb
test_hyrax-0.0.1.alpha app/jobs/ingest_file_job.rb