From cb030505af8c23636461b61ec52bdcb4dc7e590e Mon Sep 17 00:00:00 2001 From: Thomas Nagy Date: Sun, 21 Sep 2014 10:10:55 +0200 Subject: [PATCH] Issue 1487 - delete files or folders only if they exist on the filesystem --- waflib/Node.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/waflib/Node.py b/waflib/Node.py index 4c99d1c7..bc829a79 100644 --- a/waflib/Node.py +++ b/waflib/Node.py @@ -187,12 +187,13 @@ class Node(object): os.chmod(self.abspath(), val) def delete(self): - """Delete the file/folders, and remove this node from the tree. It becomes invalid after that""" + """Delete the file/folders if it exists, and remove this node from the tree. Do not use this object after calling this method.""" try: - if hasattr(self, 'children'): - shutil.rmtree(self.abspath()) - else: - os.remove(self.abspath()) + if os.path.exists(self.abspath()): + if hasattr(self, 'children'): + shutil.rmtree(self.abspath()) + else: + os.remove(self.abspath()) finally: self.evict()