mirror of https://gitlab.com/ita1024/waf.git
Issue 1487 - delete files or folders only if they exist on the filesystem
This commit is contained in:
parent
f990fca8ff
commit
cb030505af
|
@ -187,12 +187,13 @@ class Node(object):
|
||||||
os.chmod(self.abspath(), val)
|
os.chmod(self.abspath(), val)
|
||||||
|
|
||||||
def delete(self):
|
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:
|
try:
|
||||||
if hasattr(self, 'children'):
|
if os.path.exists(self.abspath()):
|
||||||
shutil.rmtree(self.abspath())
|
if hasattr(self, 'children'):
|
||||||
else:
|
shutil.rmtree(self.abspath())
|
||||||
os.remove(self.abspath())
|
else:
|
||||||
|
os.remove(self.abspath())
|
||||||
finally:
|
finally:
|
||||||
self.evict()
|
self.evict()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue