| |
@@ -14,8 +14,7 @@
|
| |
|
| |
from prunerepo.helpers import get_rpms_to_remove
|
| |
|
| |
- from copr.exceptions import CoprException
|
| |
- from copr.exceptions import CoprRequestException
|
| |
+ from copr.v3.exceptions import CoprException
|
| |
|
| |
from copr_backend.helpers import BackendConfigReader, get_redis_logger
|
| |
from copr_backend.helpers import uses_devel_repo, get_persistent_status, get_auto_prune_status, call_copr_repo
|
| |
@@ -61,7 +60,10 @@
|
| |
try:
|
| |
LOG.info("Pruning of %s/%s/%s started", username, projectdir, sub_dir_name)
|
| |
rpms = get_rpms_to_remove(chroot_path, days=prune_days, log=LOG)
|
| |
- call_copr_repo(directory=chroot_path, rpms_to_remove=rpms)
|
| |
+ if rpms:
|
| |
+ LOG.info("Going to remove %s RPMs in %s", len(rpms), chroot_path)
|
| |
+ call_copr_repo(directory=chroot_path, rpms_to_remove=rpms,
|
| |
+ logger=LOG)
|
| |
clean_copr(chroot_path, prune_days, verbose=True)
|
| |
except Exception as err: # pylint: disable=broad-except
|
| |
LOG.exception(err)
|
| |
@@ -134,7 +136,7 @@
|
| |
LOG.info("Skipped %s/%s since auto-prunning is disabled for the project",
|
| |
username, projectdir)
|
| |
return
|
| |
- except (CoprException, CoprRequestException) as exception:
|
| |
+ except CoprException as exception:
|
| |
LOG.error("Failed to get project details for %s/%s with error: %s",
|
| |
username, projectdir, exception)
|
| |
return
|
| |
@@ -179,7 +181,7 @@
|
| |
"""
|
| |
Remove whole copr build dirs if they no longer contain a RPM file
|
| |
"""
|
| |
- LOG.info("Cleaning COPR repository...")
|
| |
+ LOG.info("Cleaning COPR repository %s", path)
|
| |
for dir_name in os.listdir(path):
|
| |
dir_path = os.path.abspath(os.path.join(path, dir_name))
|
| |
|
| |
@@ -189,6 +191,11 @@
|
| |
continue
|
| |
if is_rpm_in_dir(dir_path):
|
| |
continue
|
| |
+
|
| |
+ # Note that deleting some rpm files from the directory by
|
| |
+ # run_prunerepo() actually bumps the st_mtime of the directory. So we
|
| |
+ # keep the directory here at least one another period after the last RPM
|
| |
+ # removal.
|
| |
if time.time() - os.stat(dir_path).st_mtime <= days * 24 * 3600:
|
| |
continue
|
| |
|
| |
Complements PR#1783