Prevent crashing when cleaning up file, if file is still in use

This commit is contained in:
Micah Lee 2019-02-18 12:28:02 -08:00
parent 3e2901ad8c
commit 8e200cd8b0
No known key found for this signature in database
GPG key ID: 403C2657CD994F73

View file

@ -95,10 +95,14 @@ class OnionShare(object):
"""
self.common.log('OnionShare', 'cleanup')
# cleanup files
for filename in self.cleanup_filenames:
if os.path.isfile(filename):
os.remove(filename)
elif os.path.isdir(filename):
shutil.rmtree(filename)
# Cleanup files
try:
for filename in self.cleanup_filenames:
if os.path.isfile(filename):
os.remove(filename)
elif os.path.isdir(filename):
shutil.rmtree(filename)
except:
# Don't crash if file is still in use
pass
self.cleanup_filenames = []