Sha256: 106e6a73463008ba08e19e633c941e31a338a4924e60f616b03e50eb0cdb6b5c

Contents?: true

Size: 1.44 KB

Versions: 9

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true
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)
    case file_set
    when ActiveFedora::Base
      __perform(file_set, path, user, use_valkyrie: false)
    else
      __perform(file_set, path, user, use_valkyrie: true)
    end
  end

  private

  # @note Based on the present implementation (see SHA a8597884e) of
  # the Hyrax::Actors::FileSetActor, we wouldn't need to pass the
  # `use_valkyrie` parameter.  However, I want to include this logic
  # to demonstrate that "Yes, the IngestLocalFileJob has been tested
  # for Valkyrie usage"
  def __perform(file_set, path, user, use_valkyrie:)
    file_set.label ||= File.basename(path)

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

    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

9 entries across 9 versions & 1 rubygems

Version Path
hyrax-3.6.0 app/jobs/ingest_local_file_job.rb
hyrax-3.5.0 app/jobs/ingest_local_file_job.rb
hyrax-3.4.2 app/jobs/ingest_local_file_job.rb
hyrax-3.4.1 app/jobs/ingest_local_file_job.rb
hyrax-3.4.0 app/jobs/ingest_local_file_job.rb
hyrax-3.3.0 app/jobs/ingest_local_file_job.rb
hyrax-3.2.0 app/jobs/ingest_local_file_job.rb
hyrax-3.1.0 app/jobs/ingest_local_file_job.rb
hyrax-3.0.2 app/jobs/ingest_local_file_job.rb