• 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

27.78
/app/jobs/approved_file_move_job.rb
1
# frozen_string_literal: true
2
class ApprovedFileMoveJob < ApplicationJob
1✔
3
  queue_as :default
1✔
4
  retry_on ActiveRecord::RecordNotFound
1✔
5

6
  def perform(work_id:, source_bucket:, source_key:, target_bucket:, target_key:, size:, snapshot_id:)
1✔
7
    @work_id = work_id
×
8
    @snapshot_id = snapshot_id
×
9
    @source_bucket = source_bucket
×
10
    @source_key = source_key
×
11

12
    resp = service.copy_file(source_key: key, target_bucket:, target_key:, size:)
×
13

14
    unless resp.successful?
×
15
      raise "Error copying #{key} to #{target_bucket}/#{target_key} Response #{resp.to_json}"
×
16
    end
17
    status = service.check_file(bucket: target_bucket, key: target_key)
×
18
    unless status
×
19
      raise "File check was not valid #{source_key} to #{target_bucket}/#{target_key} Response #{status.to_json}"
×
20
    end
21
    etag = if resp.respond_to? :copy_object_result
×
22
             resp.copy_object_result.etag
×
23
           else
24
             resp.etag
×
25
           end.delete('"')
26

27
    # raise("Failed to resolve the ApprovedUploadSnapshot for #{@snapshot_id}") if snapshot.nil?
28

29
    snapshot.with_lock do
×
30
      snapshot.reload
×
31
      snapshot.mark_complete(target_key, etag)
×
32
    end
33
    service.delete_s3_object(source_key, bucket: source_bucket)
×
34

35
    # Once the last file has been deleted...
36
    if service.client_s3_files(reload: true, bucket_name: source_bucket).count == 0
×
37
      # delete the source directory...
38
      service.delete_s3_object(work.s3_object_key, bucket: source_bucket)
×
39

40
      # ...and create the preservation files
41
      work_preservation.preserve!
×
42
    end
43
  end
44

45
  def key
1✔
46
    @key ||= "/#{@source_bucket}/#{@source_key}"
×
47
  end
48

49
  def work
1✔
50
    @work ||= Work.find(@work_id)
×
51
  end
52

53
  def service
1✔
54
    @service ||= S3QueryService.new(work, "postcuration")
×
55
  end
56

57
  def snapshot
1✔
58
    @snapshot ||= ApprovedUploadSnapshot.find(@snapshot_id)
×
59
  end
60

61
  def work_path
1✔
62
    @work_path ||= "#{work.doi}/#{work.id}"
×
63
  end
64

65
  def work_preservation
1✔
66
    @work_preservation ||= WorkPreservationService.new(work_id: @work_id, path: work_path)
×
67
  end
68
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