summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2019-02-18 12:28:02 -0800
committerMicah Lee <micah@micahflee.com>2019-02-18 12:28:02 -0800
commit8e200cd8b031225e13a309359142ec4442f772a0 (patch)
tree1d8f40906c94f5521955b6bc34b7867f853f6ef3
parent3e2901ad8c17a2cff59d2a3623ebe1a96164aeb5 (diff)
downloadonionshare-8e200cd8b031225e13a309359142ec4442f772a0.tar.gz
onionshare-8e200cd8b031225e13a309359142ec4442f772a0.zip
Prevent crashing when cleaning up file, if file is still in use
-rw-r--r--onionshare/onionshare.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/onionshare/onionshare.py b/onionshare/onionshare.py
index 32e56ba0..551b8314 100644
--- a/onionshare/onionshare.py
+++ b/onionshare/onionshare.py
@@ -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 = []