mirror of
https://github.com/onionshare/onionshare.git
synced 2025-02-14 05:31:25 -05:00
Calculate the time difference in a more appropriate spot (rather than on clicking Start, but when the server is ready, as it may have taken some time, but should still stop at the nominated time)
This commit is contained in:
parent
5bc1a45a1e
commit
16f34ca49e
@ -316,6 +316,15 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
||||
self.filesize_warning.setText(strings._("large_filesize", True))
|
||||
self.filesize_warning.show()
|
||||
|
||||
if self.server_status.server_shutdown_timeout_checkbox.isChecked():
|
||||
# Convert the date value to seconds between now and then
|
||||
now = QtCore.QDateTime.currentDateTime()
|
||||
self.timeout = now.secsTo(self.server_status.server_shutdown_timeout.dateTime())
|
||||
# Set the shutdown timeout value
|
||||
if self.timeout > 0:
|
||||
self.app.shutdown_timer = common.close_after_seconds(self.timeout)
|
||||
self.app.shutdown_timer.start()
|
||||
|
||||
def start_server_error(self, error):
|
||||
"""
|
||||
If there's an error when trying to start the onion service
|
||||
@ -374,9 +383,9 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
||||
|
||||
# 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.timeout > 0:
|
||||
if self.app.shutdown_timer and self.timeout > 0:
|
||||
if not self.app.shutdown_timer.is_alive():
|
||||
self.server_status.stop_server()
|
||||
self.stop_server()
|
||||
self.status_bar.showMessage(strings._('close_on_timeout',True))
|
||||
|
||||
# scroll to the bottom of the dl progress bar log pane
|
||||
|
@ -186,14 +186,6 @@ class ServerStatus(QtWidgets.QVBoxLayout):
|
||||
The server has finished starting.
|
||||
"""
|
||||
self.status = self.STATUS_STARTED
|
||||
if self.server_shutdown_timeout_checkbox.isChecked():
|
||||
# Convert the date value to seconds between now and then
|
||||
now = QtCore.QDateTime.currentDateTime()
|
||||
self.timeout = now.secsTo(self.server_shutdown_timeout.dateTime())
|
||||
# Set the shutdown timeout value
|
||||
if self.timeout > 0:
|
||||
self.app.shutdown_timer = common.close_after_seconds(self.timeout)
|
||||
self.app.shutdown_timer.start()
|
||||
self.copy_url()
|
||||
self.update()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user