• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / pdc_describe / 7ae96b6b-0a64-4479-9fa1-8ba6526e2c87

20 Mar 2024 12:42PM UTC coverage: 30.068% (-66.2%) from 96.266%
7ae96b6b-0a64-4479-9fa1-8ba6526e2c87

Pull #1701

circleci

leefaisonr
makes it so that links open in new window
Pull Request #1701: Update language on submission form

1019 of 3389 relevant lines covered (30.07%)

0.4 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

27.27
/app/jobs/dspace_file_copy_job.rb
1
# frozen_string_literal: true
2
class DspaceFileCopyJob < ApplicationJob
1✔
3
  queue_as :default
1✔
4

5
  def perform(s3_file_json:, work_id:, migration_snapshot_id:)
1✔
6
    s3_file = JSON.parse(s3_file_json)
×
7
    work = Work.find(work_id)
×
8
    new_key = s3_file["filename_display"]
×
9
    s3_key = s3_file["filename"]
×
10
    s3_size = s3_file["size"]
×
11
    resp = work.s3_query_service.copy_file(source_key: "#{dspace_bucket_name}/#{s3_key}",
×
12
                                           target_bucket: work.s3_query_service.bucket_name,
13
                                           target_key: new_key, size: s3_size)
14
    unless resp.successful?
×
15
      raise "Error copying #{s3_key} to work #{work_id} Response #{resp}"
×
16
    end
17
    if s3_size > 0 # All directories are not part of the migration snapshot
×
18
      update_migration(migration_snapshot_id, new_key, s3_size, work)
×
19
    end
20
  end
21

22
  private
1✔
23

24
    def dspace_bucket_name
1✔
25
      @dspace_bucket_name ||= Rails.configuration.s3.dspace[:bucket]
×
26
    end
27

28
    def update_migration(migration_snapshot_id, s3_key, s3_size, work)
1✔
29
      migration_snapshot = MigrationUploadSnapshot.find(migration_snapshot_id)
×
30
      migration_snapshot.with_lock do
×
31
        migration_snapshot.reload
×
32
        migration_snapshot.mark_complete(S3File.new(filename: s3_key, last_modified: DateTime.now, size: s3_size, checksum: "", work:))
×
33
        migration_snapshot.save!
×
34
      end
35
    end
36
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc