Skip to content

Commit

Permalink
backend: recreate missing repodata so that prunerepo doesn't traceback
Browse files Browse the repository at this point in the history
  • Loading branch information
FrostyX committed Oct 16, 2023
1 parent 896350c commit 7ceacf3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
7 changes: 7 additions & 0 deletions backend/run/copr_prune_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions backend/tests/test_modifyrepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'})
Expand Down

0 comments on commit 7ceacf3

Please sign in to comment.