diff --git a/backend/run/copr_prune_results.py b/backend/run/copr_prune_results.py index d5c369f77..34c961201 100755 --- a/backend/run/copr_prune_results.py +++ b/backend/run/copr_prune_results.py @@ -81,6 +81,13 @@ def run_prunerepo(chroot_path, username, projectdir, sub_dir_name, prune_days, """ try: LOG.info("Pruning of %s/%s/%s started", username, projectdir, sub_dir_name) + + repodata = os.path.join(chroot_path, "repodata") + if not os.path.exists(repodata): + LOG.info("Recreating missing repodata for %s/%s/%s", + username, projectdir, sub_dir_name) + call_copr_repo(directory=chroot_path, logger=LOG, appstream=appstream) + all_rpms = get_rpms_to_remove(chroot_path, days=prune_days, log=LOG) # See https://github.com/fedora-copr/copr/issues/1817 for more info diff --git a/backend/tests/test_modifyrepo.py b/backend/tests/test_modifyrepo.py index 8b9b465fd..0e91e6b67 100644 --- a/backend/tests/test_modifyrepo.py +++ b/backend/tests/test_modifyrepo.py @@ -584,16 +584,16 @@ def test_pruner_arg_max(self, patched_get_rpms): patched_popen.return_value.communicate.return_value = ("","") patched_popen.return_value.returncode = 0 run_prunerepo("/tmp", "blah", "blah", "blah", 0, False) - first_call = patched_popen.call_args_list[0][0][0] - assert len(patched_popen.call_args_list) == 2 + call = patched_popen.call_args_list[1][0][0] + assert len(patched_popen.call_args_list) == 3 - assert list == type(first_call) - assert 1000 < len(first_call) < 9000*2+100 + assert list == type(call) + assert 1000 < len(call) < 9000*2+100 # Test we can execute. - subprocess.check_call(["/bin/true"] + first_call) + subprocess.check_call(["/bin/true"] + call) opts = ["--rpms-to-remove", rpm_name] * 9000 - assert first_call == ["copr-repo", "--batched", "/tmp"] + opts + ["--no-appstream-metadata"] + assert call == ["copr-repo", "--batched", "/tmp"] + opts + ["--no-appstream-metadata"] @pytest.mark.parametrize('run_bg', [True, False]) @mock.patch.dict(os.environ, {'COPR_TESTSUITE_NO_OUTPUT': '1'})