only prevent the share from starting when the timeout has expired, if the timeout feature was even set at all

This commit is contained in:
Miguel Jacq 2017-11-09 18:23:11 +11:00
parent 877459a560
commit 882057eafc
No known key found for this signature in database
GPG Key ID: EEA4341C6D97A0B6
2 changed files with 14 additions and 10 deletions

View File

@ -387,11 +387,12 @@ class OnionShareGui(QtWidgets.QMainWindow):
# If the auto-shutdown timer has stopped, stop the server # If the auto-shutdown timer has stopped, stop the server
if self.server_status.status == self.server_status.STATUS_STARTED: if self.server_status.status == self.server_status.STATUS_STARTED:
if self.app.shutdown_timer and self.server_status.timer_enabled and self.timeout > 0: if self.app.shutdown_timer and self.server_status.timer_enabled:
if not self.app.shutdown_timer.is_alive(): if self.timeout > 0:
self.stop_server() if not self.app.shutdown_timer.is_alive():
self.status_bar.showMessage(strings._('close_on_timeout',True)) self.stop_server()
self.server_status.shutdown_timeout_reset() self.status_bar.showMessage(strings._('close_on_timeout',True))
self.server_status.shutdown_timeout_reset()
# scroll to the bottom of the dl progress bar log pane # scroll to the bottom of the dl progress bar log pane
# if a new download has been added # if a new download has been added

View File

@ -186,11 +186,14 @@ class ServerStatus(QtWidgets.QVBoxLayout):
Toggle starting or stopping the server. Toggle starting or stopping the server.
""" """
if self.status == self.STATUS_STOPPED: if self.status == self.STATUS_STOPPED:
# Get the timeout chosen, stripped of its seconds. This prevents confusion if the share stops at (say) 37 seconds past the minute chosen if self.timer_enabled:
self.timeout = self.server_shutdown_timeout.dateTime().toPyDateTime().replace(second=0, microsecond=0) # Get the timeout chosen, stripped of its seconds. This prevents confusion if the share stops at (say) 37 seconds past the minute chosen
# If the timeout has actually passed already before the user hit Start, refuse to start the server. self.timeout = self.server_shutdown_timeout.dateTime().toPyDateTime().replace(second=0, microsecond=0)
if QtCore.QDateTime.currentDateTime().toPyDateTime() > self.timeout: # If the timeout has actually passed already before the user hit Start, refuse to start the server.
Alert(strings._('gui_server_timeout_expired', QtWidgets.QMessageBox.Warning)) if QtCore.QDateTime.currentDateTime().toPyDateTime() > self.timeout:
Alert(strings._('gui_server_timeout_expired', QtWidgets.QMessageBox.Warning))
else:
self.start_server()
else: else:
self.start_server() self.start_server()
elif self.status == self.STATUS_STARTED: elif self.status == self.STATUS_STARTED: