From fac7dfdcf9183210f8c902c0ec411310e166da1c Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Mon, 25 Nov 2019 14:12:08 +0100 Subject: [PATCH] Fixing cleaning old project dir --- lib/cr_tf/handler.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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): -- 2.39.5