12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/jobs/cdm_migrator/restart_upload_from_middle_job.rb', line 12
def perform(work, ingest_work, user)
ordered_members = work.ordered_members.to_a
last_file_set = ordered_members.last
if last_file_set.present? and last_file_set.files.none?
CdmMigrator::CdmIngestFilesJob.perform_later(last_file_set, last_file_set.import_url, user)
end
files = ingest_work.files[ordered_members.length..-1]
files.each do |file|
url = file[:url]
last_file = ingest_work.files.last==file
::FileSet.new(import_url: url, label: file[:title]) do |fs|
fs.save
actor = Hyrax::Actors::FileSetActor.new(fs, user)
actor.create_metadata
actor.attach_file_to_work(work)
fs.attributes = file[:metadata]
fs.save!
CdmMigrator::CdmIngestFilesJob.perform_later(fs, url, user, ingest_work, last_file)
end
end
end
|