diff options
author | Micah Lee <micah@micahflee.com> | 2019-02-18 12:28:02 -0800 |
---|---|---|
committer | Micah Lee <micah@micahflee.com> | 2019-02-18 12:28:02 -0800 |
commit | 8e200cd8b031225e13a309359142ec4442f772a0 (patch) | |
tree | 1d8f40906c94f5521955b6bc34b7867f853f6ef3 | |
parent | 3e2901ad8c17a2cff59d2a3623ebe1a96164aeb5 (diff) | |
download | onionshare-8e200cd8b031225e13a309359142ec4442f772a0.tar.gz onionshare-8e200cd8b031225e13a309359142ec4442f772a0.zip |
Prevent crashing when cleaning up file, if file is still in use
-rw-r--r-- | onionshare/onionshare.py | 16 |
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 = [] |