gather_dnf.py: Do not raise error when the downloaded package is exists.

If the packages are pulled from different repos and a package is already
exists in target directory, pungi raises File exists error and breaks. This
behavior can be suspended and skipped if the package is already available.

Merges: https://pagure.io/pungi/pull-request/1696
Signed-off-by: Ozan Unsal <ounsal@redhat.com>
(cherry picked from commit dbc0e531b2)
This commit is contained in:
Ozan Unsal 2023-09-07 14:38:34 +02:00 committed by Stepan Oksanichenko
parent 8772ccca23
commit 79bc4e0c3a
Signed by: soksanichenko
GPG Key ID: AB9983172AB1E45B

View File

@ -17,6 +17,7 @@
from enum import Enum
from functools import cmp_to_key
from itertools import count, groupby
import errno
import logging
import os
import re
@ -1067,8 +1068,11 @@ class Gather(GatherBase):
# Link downloaded package in (or link package from file repo)
try:
linker.link(pkg.localPkg(), target)
except Exception:
self.logger.error("Unable to link %s from the yum cache." % pkg.name)
except Exception as ex:
if ex.errno == errno.EEXIST:
self.logger.warning("Downloaded package exists in %s", target)
else:
self.logger.error("Unable to link %s from the yum cache.", pkg.name)
raise
def log_count(self, msg, method, *args):