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

pulibrary / pdc_describe / cace366a-ffad-45f1-9b60-678e607fa527

14 May 2024 02:21PM UTC coverage: 60.862% (-35.0%) from 95.908%
cace366a-ffad-45f1-9b60-678e607fa527

push

circleci

jrgriffiniii
wip

1 of 3 new or added lines in 2 files covered. (33.33%)

1194 existing lines in 57 files now uncovered.

2076 of 3411 relevant lines covered (60.86%)

22.71 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✔
UNCOV
6
    s3_file = JSON.parse(s3_file_json)
×
UNCOV
7
    work = Work.find(work_id)
×
UNCOV
8
    new_key = s3_file["filename_display"]
×
UNCOV
9
    s3_key = s3_file["filename"]
×
UNCOV
10
    s3_size = s3_file["size"]
×
UNCOV
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)
UNCOV
14
    unless resp.successful?
×
15
      raise "Error copying #{s3_key} to work #{work_id} Response #{resp}"
×
16
    end
UNCOV
17
    if s3_size > 0 # All directories are not part of the migration snapshot
×
UNCOV
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✔
UNCOV
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✔
UNCOV
29
      migration_snapshot = MigrationUploadSnapshot.find(migration_snapshot_id)
×
UNCOV
30
      migration_snapshot.with_lock do
×
UNCOV
31
        migration_snapshot.reload
×
UNCOV
32
        migration_snapshot.mark_complete(S3File.new(filename: s3_key, last_modified: DateTime.now, size: s3_size, checksum: "", work:))
×
UNCOV
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