Implements a shutdown timer to stop a share automatically (downloaded or not) after N hours

This commit is contained in:
Miguel Jacq 2017-11-08 20:25:59 +11:00
parent 4387589b4f
commit 32108dcca2
No known key found for this signature in database
GPG key ID: EEA4341C6D97A0B6
8 changed files with 100 additions and 7 deletions

View file

@ -258,7 +258,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
self.app.stay_open = not self.settings.get('close_after_first_download')
# start onionshare http service in new thread
t = threading.Thread(target=web.start, args=(self.app.port, self.app.stay_open))
t = threading.Thread(target=web.start, args=(self.app.port, self.app.stay_open, self.app.shutdown_timeout))
t.daemon = True
t.start()
# wait for modules in thread to load, preventing a thread-related cx_Freeze crash
@ -371,6 +371,14 @@ class OnionShareGui(QtWidgets.QMainWindow):
Check for messages communicated from the web app, and update the GUI accordingly.
"""
self.update()
# If the auto-shutdown timer has stopped, stop the server
if self.server_status.status == self.server_status.STATUS_STARTED:
if self.app.shutdown_timer and self.server_status.server_shutdown_timeout.value() > 0:
if not self.app.shutdown_timer.is_alive():
self.server_status.stop_server()
self.status_bar.showMessage(strings._('close_on_timeout',True))
# scroll to the bottom of the dl progress bar log pane
# if a new download has been added
if self.new_download: