mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-25 18:52:58 -03:00
Prevent crashing when cleaning up file, if file is still in use
This commit is contained in:
parent
3e2901ad8c
commit
8e200cd8b0
1 changed files with 10 additions and 6 deletions
|
@ -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 = []
|
||||
|
|
Loading…
Add table
Reference in a new issue