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

pulibrary / pdc_describe / 4e4e59fc-9df4-4838-9fd4-6c7ea33cdb7c

07 Apr 2025 06:36PM UTC coverage: 1.283% (-94.6%) from 95.862%
4e4e59fc-9df4-4838-9fd4-6c7ea33cdb7c

Pull #1994

circleci

hectorcorrea
Switched to use the autocomplete that we aleady use for ROR. Integrated it with the existing logic for creators
Pull Request #1994: Started adding auto complete to contributors

0 of 46 new or added lines in 2 files covered. (0.0%)

4806 existing lines in 74 files now uncovered.

65 of 5065 relevant lines covered (1.28%)

0.01 hits per line

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

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

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

UNCOV
12
    begin
×
UNCOV
13
      resp = service.copy_file(source_key: key, target_bucket:, target_key:, size:)
×
UNCOV
14
      unless resp.successful?
×
UNCOV
15
        raise "Error copying #{key} to #{target_bucket}/#{target_key} Response #{resp.to_json}"
×
UNCOV
16
      end
×
UNCOV
17
    rescue Aws::S3::Errors::NoSuchKey => error
×
UNCOV
18
      status = service.check_file(bucket: source_bucket, key:)
×
UNCOV
19
      unless status
×
UNCOV
20
        raise "Missing source file #{key} can not copy to #{target_bucket}/#{target_key} Error: #{error}"
×
UNCOV
21
      end
×
UNCOV
22
    end
×
23

UNCOV
24
    status = service.check_file(bucket: target_bucket, key: target_key)
×
UNCOV
25
    unless status
×
UNCOV
26
      raise "File check was not valid #{source_key} to #{target_bucket}/#{target_key} Response #{status.to_json}"
×
UNCOV
27
    end
×
UNCOV
28
    etag = if resp.respond_to? :copy_object_result
×
UNCOV
29
             resp.copy_object_result.etag
×
UNCOV
30
           else
×
31
             resp.etag
×
UNCOV
32
           end.delete('"')
×
33

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

UNCOV
36
    snapshot.with_lock do
×
UNCOV
37
      snapshot.reload
×
UNCOV
38
      snapshot.mark_complete(target_key, etag)
×
UNCOV
39
    end
×
UNCOV
40
    service.delete_s3_object(source_key, bucket: source_bucket)
×
41

42
    # Once the last file has been deleted...
UNCOV
43
    if service.client_s3_files(reload: true, bucket_name: source_bucket).count == 0
×
44
      # delete the source directory...
UNCOV
45
      service.delete_s3_object(work.s3_object_key, bucket: source_bucket)
×
46

47
      # ...and create the preservation files
UNCOV
48
      work_preservation.preserve!
×
UNCOV
49
    end
×
UNCOV
50
  end
×
51

UNCOV
52
  def key
×
UNCOV
53
    @key ||= "/#{@source_bucket}/#{@source_key}"
×
UNCOV
54
  end
×
55

UNCOV
56
  def work
×
UNCOV
57
    @work ||= Work.find(@work_id)
×
UNCOV
58
  end
×
59

UNCOV
60
  def service
×
UNCOV
61
    @service ||= S3QueryService.new(work, "postcuration")
×
UNCOV
62
  end
×
63

UNCOV
64
  def snapshot
×
UNCOV
65
    @snapshot ||= ApprovedUploadSnapshot.find(@snapshot_id)
×
UNCOV
66
  end
×
67

UNCOV
68
  def work_path
×
UNCOV
69
    @work_path ||= "#{work.doi}/#{work.id}"
×
UNCOV
70
  end
×
71

UNCOV
72
  def work_preservation
×
UNCOV
73
    @work_preservation ||= WorkPreservationService.new(work_id: @work_id, path: work_path)
×
UNCOV
74
  end
×
UNCOV
75
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