Moved cleanup before raising (the code couldn't be reached before)

This commit is contained in:
Massimiliano Culpo 2019-04-12 23:01:26 +02:00 committed by Peter Scheibel
parent 400aa5fe51
commit 9cf650d2ab

View file

@ -1138,9 +1138,6 @@ def create_repo(root, namespace=None):
config.write(" namespace: '%s'\n" % namespace)
except (IOError, OSError) as e:
raise BadRepoError('Failed to create new repository in %s.' % root,
"Caused by %s: %s" % (type(e), e))
# try to clean up.
if existed:
shutil.rmtree(config_path, ignore_errors=True)
@ -1148,6 +1145,9 @@ def create_repo(root, namespace=None):
else:
shutil.rmtree(root, ignore_errors=True)
raise BadRepoError('Failed to create new repository in %s.' % root,
"Caused by %s: %s" % (type(e), e))
return full_path, namespace