mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-27 00:09:50 -05:00
Make auto-stop timer work on CLI when an upload is still in progress on expiry
This commit is contained in:
parent
61d2e6cc5f
commit
875b538347
@ -198,6 +198,13 @@ def main(cwd=None):
|
||||
print(strings._("close_on_timeout"))
|
||||
web.stop(app.port)
|
||||
break
|
||||
if mode == 'receive':
|
||||
if web.receive_mode.upload_count == 0 or not web.receive_mode.uploads_in_progress:
|
||||
print(strings._("close_on_timeout"))
|
||||
web.stop(app.port)
|
||||
break
|
||||
else:
|
||||
web.receive_mode.can_upload = False
|
||||
# Allow KeyboardInterrupt exception to be handled with threads
|
||||
# https://stackoverflow.com/questions/3788208/python-threading-ignores-keyboardinterrupt-exception
|
||||
time.sleep(0.2)
|
||||
|
@ -20,6 +20,7 @@ class ReceiveModeWeb(object):
|
||||
|
||||
self.can_upload = True
|
||||
self.upload_count = 0
|
||||
self.uploads_in_progress = []
|
||||
|
||||
self.define_routes()
|
||||
|
||||
@ -273,6 +274,8 @@ class ReceiveModeRequest(Request):
|
||||
'content_length': self.content_length
|
||||
})
|
||||
|
||||
self.web.receive_mode.uploads_in_progress.append(self.upload_id)
|
||||
|
||||
self.previous_file = None
|
||||
|
||||
def _get_file_stream(self, total_content_length, content_type, filename=None, content_length=None):
|
||||
@ -298,6 +301,7 @@ class ReceiveModeRequest(Request):
|
||||
self.web.add_request(self.web.REQUEST_UPLOAD_FINISHED, self.path, {
|
||||
'id': self.upload_id
|
||||
})
|
||||
self.web.receive_mode.uploads_in_progress.remove(self.upload_id)
|
||||
|
||||
|
||||
def file_write_func(self, filename, length):
|
||||
|
Loading…
Reference in New Issue
Block a user