mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-28 08:49:30 -05:00
Gracefully handle exceptions while writing a file during a receive mode transfer (like out of disk space error)
This commit is contained in:
parent
28eaf2f2be
commit
09c2696c27
@ -193,10 +193,15 @@ class ReceiveModeFile(object):
|
||||
"""
|
||||
if self.upload_error or (not self.onionshare_request.stop_q.empty()):
|
||||
self.close()
|
||||
self.onionshare_request.close()
|
||||
self.onionshare_request.close(self.upload_error)
|
||||
return
|
||||
|
||||
try:
|
||||
bytes_written = self.f.write(b)
|
||||
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):
|
||||
@ -394,8 +399,12 @@ class ReceiveModeRequest(Request):
|
||||
'progress': self.progress
|
||||
})
|
||||
|
||||
def file_close_func(self, filename):
|
||||
def file_close_func(self, filename, upload_error=False):
|
||||
"""
|
||||
This function gets called when a specific file is closed.
|
||||
"""
|
||||
self.progress[filename]['complete'] = True
|
||||
|
||||
# If the file tells us there was an upload error, let the request know as well
|
||||
if upload_error:
|
||||
self.upload_error = True
|
||||
|
Loading…
Reference in New Issue
Block a user