Sha256: 8136a712802afef03ec09720690561334620514ce9d9326025357c9e899cba6a

Contents?: true

Size: 878 Bytes

Versions: 5

Compression:

Stored size: 878 Bytes

Contents

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

  # @param [FileSet] file_set
  # @param [String] path
  # @param [User] user
  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

5 entries across 5 versions & 1 rubygems

Version Path
hyrax-3.0.1 app/jobs/ingest_local_file_job.rb
hyrax-3.0.0 app/jobs/ingest_local_file_job.rb
hyrax-3.0.0.pre.rc4 app/jobs/ingest_local_file_job.rb
hyrax-3.0.0.pre.rc3 app/jobs/ingest_local_file_job.rb
hyrax-3.0.0.pre.rc2 app/jobs/ingest_local_file_job.rb