From 0db4c0920f14d656bf72469a7db151ca5d41a8b7 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Sep 02 2020 13:34:18 +0000 Subject: [PATCH 1/2] cli: download_file redownload if we've larger file Fixes: https://pagure.io/koji/issue/2465 --- diff --git a/cli/koji_cli/lib.py b/cli/koji_cli/lib.py index 6454ef9..dc208d8 100644 --- a/cli/koji_cli/lib.py +++ b/cli/koji_cli/lib.py @@ -527,7 +527,7 @@ def download_file(url, relpath, quiet=False, noprogress=False, size=None, # closing needs to be used for requests < 2.18.0 with closing(requests.get(url, headers=headers, stream=True)) as response: - if response.status_code == 200: # full content provided? + if response.status_code in (200, 416): # full content provided or reaching behing EOF # rewrite in such case f.close() f = open(relpath, 'wb') From c5a233c44e4e3643a067d5abac60dbe96043935c Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Sep 02 2020 14:23:49 +0000 Subject: [PATCH 2/2] don't check size for signed rpms --- diff --git a/cli/koji_cli/lib.py b/cli/koji_cli/lib.py index dc208d8..890ba80 100644 --- a/cli/koji_cli/lib.py +++ b/cli/koji_cli/lib.py @@ -551,12 +551,14 @@ def download_rpm(build, rpm, topurl, sigkey=None, quiet=False, noprogress=False) pi = koji.PathInfo(topdir=topurl) if sigkey: fname = pi.signed(rpm, sigkey) + filesize = None else: fname = pi.rpm(rpm) + filesize = rpm['size'] url = os.path.join(pi.build(build), fname) path = os.path.basename(fname) - download_file(url, path, quiet=quiet, noprogress=noprogress, filesize=rpm['size']) + download_file(url, path, quiet=quiet, noprogress=noprogress, filesize=filesize) # size - we have stored size only for unsigned copies if not sigkey: