From 32208314d424d6e75d6566b5bcc796e574b20878 Mon Sep 17 00:00:00 2001 From: Jana Cupova Date: Jul 13 2022 12:45:19 +0000 Subject: CLI: More details when files conflict in download-task Fixes: https://pagure.io/koji/issue/3433 --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index b59c37d..0548329 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -7015,6 +7015,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 diff --git a/tests/test_cli/test_download_task.py b/tests/test_cli/test_download_task.py index c35d4a6..a399810 100644 --- a/tests/test_cli/test_download_task.py +++ b/tests/test_cli/test_download_task.py @@ -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)