Class: IngestLocalFileJob

Inherits:
ActiveJob::Base
  • Object
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
# 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))
    FileUtils.rm(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
end