Class: IngestLocalFileJob

Inherits:
Hyrax::ApplicationJob show all
Defined in:
app/jobs/ingest_local_file_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(file_set, path, user) ⇒ Object

Parameters:

  • file_set (FileSet)
  • path (String)
  • user (User)

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/jobs/ingest_local_file_job.rb', line 7

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)
  else
    Hyrax.config.callback.run(:after_import_local_file_failure, file_set, user, path)
  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)
end