From 9276ae51f22b46ad405ac0783762ca833e9e8d6e Mon Sep 17 00:00:00 2001 From: Samir Jha Date: Thu, 22 Aug 2019 20:56:03 +0000 Subject: [PATCH] Fixes #27717 - Support pulp3 content uploads --- lib/hammer_cli_katello/repository.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/hammer_cli_katello/repository.rb b/lib/hammer_cli_katello/repository.rb index c8321ddb..07159943 100644 --- a/lib/hammer_cli_katello/repository.rb +++ b/lib/hammer_cli_katello/repository.rb @@ -382,12 +382,12 @@ def content_upload_resource private def upload_file(file, opts = {}) - upload_id = create_content_upload + total_size = File.size(file) + upload_id = create_content_upload(total_size) repo_id = get_identifier filename = File.basename(file.path) update_content_upload(upload_id, repo_id, file) - file.rewind content = file.read @@ -410,9 +410,12 @@ def upload_file(file, opts = {}) content_upload_resource.call(:destroy, :repository_id => get_identifier, :id => upload_id) end - def create_content_upload - response = content_upload_resource.call(:create, :repository_id => get_identifier) - + def create_content_upload(size) + params = { + :repository_id => get_identifier, + :size => size + } + response = content_upload_resource.call(:create, params) response["upload_id"] end @@ -424,10 +427,10 @@ def update_content_upload(upload_id, repo_id, file) :offset => offset, :id => upload_id, :content => content, + :size => file.size, :repository_id => repo_id, :multipart => true } - # To workaround rest-client bug with false negative warnings, # see https://github.com/rest-client/rest-client/pull/670 for more details silence_warnings do