From d133806c841be6ea854dfb141c12db17538e89d6 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Mar 30 2017 13:45:59 +0000 Subject: avoid duplicate hard linking --- diff --git a/builder/kojid b/builder/kojid index 4c6665c..63adc3a 100755 --- a/builder/kojid +++ b/builder/kojid @@ -5185,7 +5185,12 @@ enabled=1 bnplet = bnp[0].lower() pkgwriter.write(bnplet + '/' + bnp + '\n') koji.ensuredir(os.path.join(self.repodir, bnplet)) - os.symlink(ml_pkg, os.path.join(self.repodir, bnplet, bnp)) + dst = os.path.join(self.repodir, bnplet, bnp) + if os.path.exists(dst): + self.logger.warning("Path exists: %r", dst) + continue + self.logger.debug("os.symlink(%r, %r)", ml_pkg, dst) + os.symlink(ml_pkg, dst) self.keypaths[bnp] = ml_pkg @@ -5240,7 +5245,9 @@ enabled=1 pkglist.write(bnplet + '/' + bnp + '\n') koji.ensuredir(os.path.join(self.repodir, bnplet)) self.keypaths[bnp] = pkgpath - os.symlink(pkgpath, os.path.join(self.repodir, bnplet, bnp)) + dst = os.path.join(self.repodir, bnplet, bnp) + self.logger.debug("os.symlink(%r, %r(", pkgpath, dst) + os.symlink(pkgpath, dst) pkglist.close() if len(fs_missing) > 0: raise koji.GenericError('Packages missing from the filesystem:\n' + diff --git a/hub/kojihub.py b/hub/kojihub.py index 17f89d1..bd96cb9 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -12351,14 +12351,19 @@ class HostExports(object): bnp = os.path.basename(rpmpath) bnplet = bnp[0].lower() koji.ensuredir(os.path.join(archdir, bnplet)) + l_dst = os.path.join(archdir, bnplet, bnp) + if os.path.exists(l_dst): + logger.warning("Path exists: %s", l_dst) + continue + logger.debug("os.link(%r, %r)", rpmpath, l_dst) try: - os.link(rpmpath, os.path.join(archdir, bnplet, bnp)) + os.link(rpmpath, l_dst) except OSError, ose: if ose.errno == 18: shutil.copy2( rpmpath, os.path.join(archdir, bnplet, bnp)) else: - raise ose + raise safer_move(src, dst) def isEnabled(self):