Issue 1487 - there can be race conditions or other kinds of errors to ignore

This commit is contained in:
Thomas Nagy 2014-09-22 19:31:01 +02:00
parent 02ad15eb17
commit 620dea5fb7
No known key found for this signature in database
GPG Key ID: 67A565EDFDF90E64
1 changed files with 5 additions and 2 deletions

View File

@ -187,13 +187,16 @@ class Node(object):
os.chmod(self.abspath(), val)
def delete(self):
"""Delete the file/folders if it exists, and remove this node from the tree. Do not use this object after calling this method."""
"""Delete the file/folder, and remove this node from the tree. Do not use this object after calling this method."""
try:
if os.path.exists(self.abspath()):
try:
if hasattr(self, 'children'):
shutil.rmtree(self.abspath())
else:
os.remove(self.abspath())
except OSError as e:
if os.path.exists(self.abspath()):
raise e
finally:
self.evict()