Make auto-stop timer work on CLI when an upload is still in progress on expiry

This commit is contained in:
Miguel Jacq 2018-10-02 15:41:29 +10:00
parent 61d2e6cc5f
commit 875b538347
No known key found for this signature in database
GPG Key ID: EEA4341C6D97A0B6
2 changed files with 11 additions and 0 deletions

View File

@ -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)

View File

@ -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):