summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2019-02-12 15:54:25 -0800
committerMicah Lee <micah@micahflee.com>2019-02-12 15:54:25 -0800
commite625d3b009e9cc3126813c0cd74b9d804e1a201e (patch)
treeac7676ccb622ad8b312e437435f62671ad3a09b2
parent09c2696c27eb9a8bbf7a7d639530de64a4526c70 (diff)
downloadonionshare-e625d3b009e9cc3126813c0cd74b9d804e1a201e.tar.gz
onionshare-e625d3b009e9cc3126813c0cd74b9d804e1a201e.zip
Catch more exceptions in ReceiveModeFile that trigger on a full disk
-rw-r--r--onionshare/web/receive_mode.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/onionshare/web/receive_mode.py b/onionshare/web/receive_mode.py
index ea1dc2fd..2c37998c 100644
--- a/onionshare/web/receive_mode.py
+++ b/onionshare/web/receive_mode.py
@@ -198,21 +198,24 @@ class ReceiveModeFile(object):
try:
bytes_written = self.f.write(b)
+ self.onionshare_write_func(self.onionshare_filename, bytes_written)
+
except:
- # If we can't write the file, close early
self.upload_error = True
- return
- self.onionshare_write_func(self.onionshare_filename, bytes_written)
def close(self):
"""
Custom close method that calls out to onionshare_close_func
"""
- self.f.close()
+ try:
+ self.f.close()
- if not self.upload_error:
- # Rename the in progress file to the final filename
- os.rename(self.filename_in_progress, self.filename)
+ if not self.upload_error:
+ # Rename the in progress file to the final filename
+ os.rename(self.filename_in_progress, self.filename)
+
+ except:
+ self.upload_error = True
self.onionshare_close_func(self.onionshare_filename)