From: Frank Brehm Date: Mon, 25 Nov 2019 13:12:08 +0000 (+0100) Subject: Fixing cleaning old project dir X-Git-Tag: 1.3.12~7^2~2 X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=fac7dfdcf9183210f8c902c0ec411310e166da1c;p=pixelpark%2Fcreate-terraform.git Fixing cleaning old project dir --- diff --git a/lib/cr_tf/handler.py b/lib/cr_tf/handler.py index 56fcbdd..b4b95df 100644 --- a/lib/cr_tf/handler.py +++ b/lib/cr_tf/handler.py @@ -2072,14 +2072,15 @@ class CreateTerraformHandler(BaseHandler): LOG.debug(_("Directory {!r} is already clean.").format(str(self.project_dir))) return for pfile in files: - if pfile.is_dir(): - LOG.debug(_("Removing recursive directory {!r} ...").format(str(pfile))) - if not self.simulate: - shutil.rmtree(str(pfile)) - else: - LOG.debug(_("Removing {!r} ...").format(str(pfile))) - if not self.simulate: - pfile.unlink() + if pfile.exists(): + if pfile.is_dir(): + LOG.debug(_("Removing recursive directory {!r} ...").format(str(pfile))) + if not self.simulate: + shutil.rmtree(str(pfile)) + else: + LOG.debug(_("Removing {!r} ...").format(str(pfile))) + if not self.simulate: + pfile.unlink() # -------------------------------------------------------------------------- def create_terraform_files(self):