Changed check to correct build import dir

This commit is contained in:
Brendan Reilly 2017-10-17 14:17:19 -04:00 committed by Mike McLean
parent 57dbc9ac01
commit 036377352c

View file

@ -5195,8 +5195,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)
@ -5227,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)
@ -5314,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)