Blob Blame History Raw
From 85be35190444df56175559ad2d839e52d99d7f77 Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Mon, 17 Jun 2019 17:39:41 -0700
Subject: [PATCH] Fix downloading packages for updates with multiple builds

I inadvertently broke this in #3148 - sorry. I tried to make
the handling of the args list cleaner in that commit, but
overlooked that initializing it outside of the `for build in`
loop meant it'd just keep getting appended to, it doesn't get
recreated for each build - so by the time you get to the second
build in an update, you're trying to do something like:

koji download-build foo-1.0-1 bar-1.0-1

which isn't allowed (that's why we run one command per build in
the first place, life would be easier if Koji let us pass it
multiple NVRs...)

Fix this simply by (re)initializing `args` inside the loop, not
outside it.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
---
 bodhi/client/__init__.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/bodhi/client/__init__.py b/bodhi/client/__init__.py
index d9f6998a..f325fd53 100644
--- a/bodhi/client/__init__.py
+++ b/bodhi/client/__init__.py
@@ -724,12 +724,12 @@ def download(url, **kwargs):
             # Not sure if we need a check for > expecteds, I don't
             # *think* that should ever be possible for these opts.
 
-            args = ['koji', 'download-build']
-            if debuginfo:
-                args.append('--debuginfo')
             for update in resp.updates:
                 click.echo("Downloading packages from {0}".format(update['alias']))
                 for build in update['builds']:
+                    args = ['koji', 'download-build']
+                    if debuginfo:
+                        args.append('--debuginfo')
                     # subprocess is icky, but koji module doesn't
                     # expose this in any usable way, and we don't want
                     # to rewrite it here.
-- 
2.21.0