]> Frank Brehm's Git Trees - pixelpark/create-terraform.git/commitdiff
Fixing cleaning old project dir
authorFrank Brehm <frank.brehm@pixelpark.com>
Mon, 25 Nov 2019 13:12:08 +0000 (14:12 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Mon, 25 Nov 2019 13:12:08 +0000 (14:12 +0100)
lib/cr_tf/handler.py

index 56fcbdd0013e07f02563de20124c56258aa0853c..b4b95dfe89a38200a56cab91b97efe88b1f46332 100644 (file)
@@ -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):