diff --git a/onionshare/__init__.py b/onionshare/__init__.py index 715c5571..42294ec1 100644 --- a/onionshare/__init__.py +++ b/onionshare/__init__.py @@ -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) diff --git a/onionshare/web/receive_mode.py b/onionshare/web/receive_mode.py index 60909a23..4ea95201 100644 --- a/onionshare/web/receive_mode.py +++ b/onionshare/web/receive_mode.py @@ -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):