Class: DspaceBitstreamCopyJob
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- DspaceBitstreamCopyJob
- Defined in:
- app/jobs/dspace_bitstream_copy_job.rb
Instance Method Summary collapse
-
#perform(dspace_files_json:, work_id:, migration_snapshot_id:) ⇒ Object
For each file from DSpace, queue up a migration.
Instance Method Details
#perform(dspace_files_json:, work_id:, migration_snapshot_id:) ⇒ Object
For each file from DSpace, queue up a migration. If the file contains characters that are not S3 safe, re-name the file. Note that the dspace_file.filename_display will be the file’s key in S3. Files that are re-named must be re-named sequentially, and we must provide a list of all of the re-naming that occurred, and include that file in what is uploaded to S3.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/jobs/dspace_bitstream_copy_job.rb', line 11 def perform(dspace_files_json:, work_id:, migration_snapshot_id:) dspace_files = JSON.parse(dspace_files_json).map { |json_file| S3File.from_json(json_file) } @work = Work.find(work_id) frms = FileRenameMappingService.new(upload_snapshot: MigrationUploadSnapshot.find(migration_snapshot_id)) dspace_files.each do |dspace_file| if FileRenameService.new(filename: dspace_file.filename_display).needs_rename? # Rename files so they are S3 safe dspace_file.filename_display = frms.renamed_files[dspace_file.filename_display] end migrate_file(dspace_file, migration_snapshot_id) end upload_rename_mapping(frms) end |