From f5cc05846a9e586ce1ed73275300104f9b19f913 Mon Sep 17 00:00:00 2001 From: Brendan Reilly Date: Oct 09 2017 19:18:59 +0000 Subject: [PATCH 1/2] cg_import fails immediately if build directory already exists --- diff --git a/hub/kojihub.py b/hub/kojihub.py index 8516c76..5ec8924 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -5196,6 +5196,8 @@ def cg_import(metadata, directory): - a filename containing the metadata """ + if os.path.lexists(directory): + raise koji.GenericError("Destination directory exists: %s" % directory) importer = CG_Importer() return importer.do_import(metadata, directory) From abfde88dd4be33c260de24745c2fac5f0bf485c4 Mon Sep 17 00:00:00 2001 From: Brendan Reilly Date: Oct 17 2017 18:19:12 +0000 Subject: [PATCH 2/2] Changed check to correct build import dir --- diff --git a/hub/kojihub.py b/hub/kojihub.py index 5ec8924..034b592 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -5196,8 +5196,6 @@ def cg_import(metadata, directory): - a filename containing the metadata """ - if os.path.lexists(directory): - raise koji.GenericError("Destination directory exists: %s" % directory) importer = CG_Importer() return importer.do_import(metadata, directory) @@ -5228,6 +5226,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) @@ -5315,6 +5314,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)