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

pulibrary / pdc_describe / 9091a1ae-29be-458c-984a-339d213919c4

12 Dec 2024 07:41PM UTC coverage: 26.434% (-69.7%) from 96.113%
9091a1ae-29be-458c-984a-339d213919c4

Pull #2000

circleci

jrgriffiniii
Removing integration with ActiveStorage
Pull Request #2000: Bump actionpack from 7.2.1.1 to 7.2.2.1

945 of 3575 relevant lines covered (26.43%)

0.35 hits per line

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

25.0
/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

36
    rescue ActiveRecord::StatementInvalid
37
      ActiveRecord::Base.connection_pool.release_connection
×
38
      retry
×
39
    end
40
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