mirror of
https://github.com/onionshare/onionshare.git
synced 2025-05-03 15:05:11 -04:00
Prevent a scheduled share from starting after the scheduled time has passed. Add a test for this
This commit is contained in:
parent
8889d3d586
commit
00a8b88264
3 changed files with 41 additions and 3 deletions
|
@ -312,11 +312,16 @@ class ServerStatus(QtWidgets.QWidget):
|
|||
Toggle starting or stopping the server.
|
||||
"""
|
||||
if self.status == self.STATUS_STOPPED:
|
||||
can_start = True
|
||||
if self.common.settings.get('startup_timer'):
|
||||
if self.local_only:
|
||||
self.scheduled_start = self.startup_timer.dateTime().toPyDateTime()
|
||||
else:
|
||||
self.scheduled_start = self.startup_timer.dateTime().toPyDateTime().replace(second=0, microsecond=0)
|
||||
# If the timer has actually passed already before the user hit Start, refuse to start the server.
|
||||
if QtCore.QDateTime.currentDateTime().toPyDateTime() > self.scheduled_start:
|
||||
can_start = False
|
||||
Alert(self.common, strings._('gui_server_startup_timer_expired'), QtWidgets.QMessageBox.Warning)
|
||||
if self.common.settings.get('shutdown_timeout'):
|
||||
if self.local_only:
|
||||
self.timeout = self.shutdown_timeout.dateTime().toPyDateTime()
|
||||
|
@ -325,10 +330,9 @@ class ServerStatus(QtWidgets.QWidget):
|
|||
self.timeout = self.shutdown_timeout.dateTime().toPyDateTime().replace(second=0, microsecond=0)
|
||||
# If the timeout has actually passed already before the user hit Start, refuse to start the server.
|
||||
if QtCore.QDateTime.currentDateTime().toPyDateTime() > self.timeout:
|
||||
can_start = False
|
||||
Alert(self.common, strings._('gui_server_timeout_expired'), QtWidgets.QMessageBox.Warning)
|
||||
else:
|
||||
self.start_server()
|
||||
else:
|
||||
if can_start:
|
||||
self.start_server()
|
||||
elif self.status == self.STATUS_STARTED:
|
||||
self.stop_server()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue