From 21fefc4c77f569257f7688c32221e35adcad10e9 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Oct 17 2017 20:41:24 +0000 Subject: PR#631: cg_import fails immediately if build directory already exists Merges #631 https://pagure.io/koji/pull-request/631 Merges #425 https://pagure.io//koji/issue/425 --- diff --git a/hub/kojihub.py b/hub/kojihub.py index 10eed1b..2579b32 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -5225,6 +5225,7 @@ class CG_Importer(object): self.assert_policy() self.set_volume() + self.check_build_dir() koji.plugin.run_callbacks('preImport', type='cg', metadata=metadata, directory=directory) @@ -5312,6 +5313,13 @@ class CG_Importer(object): self.buildinfo['volume_name'] = vol['name'] + def check_build_dir(self): + """Check that the import directory does not already exist""" + path = koji.pathinfo.build(self.buildinfo) + if os.path.lexists(path): + raise koji.GenericError("Destination directory already exists: %s" % path) + + def prep_build(self): metadata = self.metadata buildinfo = get_build(metadata['build'], strict=False)