Sha256: 906ed561a2a02c02f47caa0620f1a74ab8d1fd896e32d399ecd8ca1015a94667

Contents?: true

Size: 1.02 KB

Versions: 12

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true
##
# Ingest a local file using ActiveFedora & FileSetActor.
class IngestLocalFileJob < Hyrax::ApplicationJob
  queue_as Hyrax.config.ingest_queue_name

  # @param [FileSet, Hyrax::FileSet] file_set
  # @param [String] path
  # @param [User] user
  def perform(file_set, path, user)
    __perform(file_set, path, user)
  end

  private

  def __perform(file_set, path, user)
    file_set.label ||= File.basename(path)

    actor = Hyrax::Actors::FileSetActor.new(file_set, user)

    if actor.create_content(File.open(path))
      Hyrax.config.callback.run(:after_import_local_file_success, file_set, user, path, warn: false)
    else
      Hyrax.config.callback.run(:after_import_local_file_failure, file_set, user, path, warn: false)
    end
  rescue SystemCallError
    # This is generic in order to handle Errno constants raised when accessing files
    # @see https://ruby-doc.org/core-2.5.3/Errno.html
    Hyrax.config.callback.run(:after_import_local_file_failure, file_set, user, path, warn: false)
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
hyrax-5.0.2 app/jobs/ingest_local_file_job.rb
hyrax-5.0.1 app/jobs/ingest_local_file_job.rb
hyrax-5.0.0 app/jobs/ingest_local_file_job.rb
hyrax-5.0.0.rc3 app/jobs/ingest_local_file_job.rb
hyrax-5.0.0.rc2 app/jobs/ingest_local_file_job.rb
hyrax-5.0.0.rc1 app/jobs/ingest_local_file_job.rb
hyrax-4.0.0 app/jobs/ingest_local_file_job.rb
hyrax-4.0.0.rc3 app/jobs/ingest_local_file_job.rb
hyrax-4.0.0.rc2 app/jobs/ingest_local_file_job.rb
hyrax-4.0.0.rc1 app/jobs/ingest_local_file_job.rb
hyrax-4.0.0.beta2 app/jobs/ingest_local_file_job.rb
hyrax-4.0.0.beta1 app/jobs/ingest_local_file_job.rb