CLI: More details when files conflict in download-task

Fixes: https://pagure.io/koji/issue/3433
This commit is contained in:
Jana Cupova 2022-07-12 08:55:40 +02:00 committed by Tomas Kopecek
parent 37b207cf44
commit 310331c3f7
2 changed files with 11 additions and 1 deletions

View file

@ -7005,6 +7005,15 @@ def anon_handle_download_task(options, session, args):
if not suboptions.dirpertask:
not_uniques = list({x for x in downloads_new_names if downloads_new_names.count(x) > 1})
if not_uniques:
files_dict = {}
for nu in not_uniques:
for (_, _, vol, new_filename, task_id) in downloads:
if new_filename == nu[0] and vol == nu[1]:
files_dict.setdefault(new_filename, {'vol': vol, 'tasks': []})
files_dict[new_filename]['tasks'].append(task_id)
for key, value in files_dict.items():
warn('Duplicate file %s for volume %s (tasks [%s])' % (key, value['vol'],
", ".join(value['tasks'])))
error("Download files names conflict, use --dirpertask")
# perform the download

View file

@ -702,7 +702,8 @@ Options:
self.assert_system_exit(
anon_handle_download_task,
self.options, self.session, args,
stderr="Download files names conflict, use --dirpertask\n",
stderr="Duplicate file somerpm.noarch.rpm for volume DEFAULT (tasks [22222, 55555])\n"
"Download files names conflict, use --dirpertask\n",
stdout='',
activate_session=None,
exit_code=1)