From f6e3488f4321fb669f2b861ca943ed6b33448790 Mon Sep 17 00:00:00 2001 From: Jana Cupova Date: Sep 22 2022 14:22:13 +0000 Subject: Add number and size for download-build Fixes: https://pagure.io/koji/issue/3515 --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index b347683..4d279ee 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -6723,13 +6723,18 @@ def anon_handle_download_build(options, session, args): warn("No such sigkey %s for rpm %s" % (suboptions.key, nvra)) rpms.remove(rpm) + size = len(rpms) + len(archives) + number = 0 + # run the download for rpm in rpms: - download_rpm(info, rpm, suboptions.topurl, sigkey=suboptions.key, - quiet=suboptions.quiet, noprogress=suboptions.noprogress) + number += 1 + download_rpm(info, rpm, suboptions.topurl, sigkey=suboptions.key, quiet=suboptions.quiet, + noprogress=suboptions.noprogress, num=number, size=size) for archive in archives: - download_archive(info, archive, suboptions.topurl, - quiet=suboptions.quiet, noprogress=suboptions.noprogress) + number += 1 + download_archive(info, archive, suboptions.topurl, quiet=suboptions.quiet, + noprogress=suboptions.noprogress, num=number, size=size) def anon_handle_download_logs(options, session, args): diff --git a/cli/koji_cli/lib.py b/cli/koji_cli/lib.py index 2c69ff6..ec75601 100644 --- a/cli/koji_cli/lib.py +++ b/cli/koji_cli/lib.py @@ -617,7 +617,8 @@ def download_file(url, relpath, quiet=False, noprogress=False, size=None, print('') -def download_rpm(build, rpm, topurl, sigkey=None, quiet=False, noprogress=False): +def download_rpm(build, rpm, topurl, sigkey=None, quiet=False, noprogress=False, num=None, + size=None): "Wrapper around download_file, do additional checks for rpm files" pi = koji.PathInfo(topdir=topurl) if sigkey: @@ -629,7 +630,8 @@ def download_rpm(build, rpm, topurl, sigkey=None, quiet=False, noprogress=False) url = os.path.join(pi.build(build), fname) path = os.path.basename(fname) - download_file(url, path, quiet=quiet, noprogress=noprogress, filesize=filesize) + download_file(url, path, quiet=quiet, noprogress=noprogress, filesize=filesize, num=num, + size=size) # size - we have stored size only for unsigned copies if not sigkey: @@ -654,7 +656,7 @@ def download_rpm(build, rpm, topurl, sigkey=None, quiet=False, noprogress=False) error("Downloaded rpm %s doesn't match db, deleting" % path) -def download_archive(build, archive, topurl, quiet=False, noprogress=False): +def download_archive(build, archive, topurl, quiet=False, noprogress=False, num=None, size=None): "Wrapper around download_file, do additional checks for archive files" pi = koji.PathInfo(topdir=topurl) @@ -673,7 +675,8 @@ def download_archive(build, archive, topurl, quiet=False, noprogress=False): url = os.path.join(directory, archive['filename']) path = archive['filename'] - download_file(url, path, quiet=quiet, noprogress=noprogress, filesize=archive['size']) + download_file(url, path, quiet=quiet, noprogress=noprogress, filesize=archive['size'], num=num, + size=size) # check size if os.path.getsize(path) != archive['size']: