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') self.common.log('OnionShare', 'cleanup')
# cleanup files # Cleanup files
for filename in self.cleanup_filenames: try:
if os.path.isfile(filename): for filename in self.cleanup_filenames:
os.remove(filename) if os.path.isfile(filename):
elif os.path.isdir(filename): os.remove(filename)
shutil.rmtree(filename) elif os.path.isdir(filename):
shutil.rmtree(filename)
except:
# Don't crash if file is still in use
pass
self.cleanup_filenames = [] self.cleanup_filenames = []