Issue 1487 - delete files or folders only if they exist on the filesystem

This commit is contained in:
Thomas Nagy 2014-09-21 10:10:55 +02:00
parent f990fca8ff
commit cb030505af
No known key found for this signature in database
GPG Key ID: 67A565EDFDF90E64
1 changed files with 6 additions and 5 deletions

View File

@ -187,8 +187,9 @@ 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 os.path.exists(self.abspath()):
if hasattr(self, 'children'): if hasattr(self, 'children'):
shutil.rmtree(self.abspath()) shutil.rmtree(self.abspath())
else: else: