Class: Actions::Pulp3::Repository::CommitUpload

Inherits:
AbstractAsyncTask show all
Defined in:
app/lib/actions/pulp3/repository/commit_upload.rb

Overview

Creates an artifacts

Instance Method Summary collapse

Methods inherited from AbstractAsyncTask

#cancel, #cancel!, #combined_tasks, #done?, #external_task, #humanized_state, #new_or_existing_objects, #pulp_tasks, #rescue_external_task, #run, #task_groups

Methods inherited from Abstract

#smart_proxy

Instance Method Details

#check_for_errorsObject



28
29
30
31
32
33
34
35
36
# File 'app/lib/actions/pulp3/repository/commit_upload.rb', line 28

def check_for_errors
  combined_tasks.each do |task|
    if unique_error task.error
      warn _("Duplicate artifact detected")
    else
      super
    end
  end
end

#invoke_external_taskObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/lib/actions/pulp3/repository/commit_upload.rb', line 10

def invoke_external_task
  repo = ::Katello::Repository.find(input[:repository_id])
  repo_backend_service = repo.backend_service(smart_proxy)
  uploads_api = repo_backend_service.core_api.uploads_api

  duplicate_sha_artifact_list = ::Katello::Pulp3::Api::Core.new(smart_proxy).artifacts_api.list("sha256": input[:sha256])
  duplicate_sha_artifact_href = duplicate_sha_artifact_list&.results&.first&.pulp_href
  if duplicate_sha_artifact_href
    uploads_api.delete(input[:upload_href]) if input[:upload_href]
    output[:artifact_href] = duplicate_sha_artifact_href
    output[:pulp_tasks] = nil
  else
    output[:artifact_href] = nil
    upload_commit = repo_backend_service.core_api.upload_commit_class.new(sha256: input[:sha256])
    output[:pulp_tasks] = [uploads_api.commit(input[:upload_href], upload_commit)]
  end
end

#plan(repository, smart_proxy, upload_href, sha256) ⇒ Object



6
7
8
# File 'app/lib/actions/pulp3/repository/commit_upload.rb', line 6

def plan(repository, smart_proxy, upload_href, sha256)
  plan_self(:repository_id => repository.id, :smart_proxy_id => smart_proxy.id, :upload_href => upload_href, :sha256 => sha256)
end

#unique_error(message) ⇒ Object



38
39
40
# File 'app/lib/actions/pulp3/repository/commit_upload.rb', line 38

def unique_error(message)
  message&.include?("code='unique'")
end