mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-10 19:52:50 -03:00
Better fix for preventing timeout firing if a download is not yet done (works for CLI as well as GUI)
This commit is contained in:
parent
2eb7bca242
commit
91a0c60189
3 changed files with 6 additions and 12 deletions
|
@ -134,7 +134,7 @@ def main(cwd=None):
|
|||
while t.is_alive():
|
||||
if app.shutdown_timeout > 0:
|
||||
# if the shutdown timer was set and has run out, stop the server
|
||||
if not app.shutdown_timer.is_alive():
|
||||
if not app.shutdown_timer.is_alive() and web.done:
|
||||
print(strings._("close_on_timeout"))
|
||||
web.stop(app.port)
|
||||
break
|
||||
|
|
|
@ -187,6 +187,7 @@ def check_slug_candidate(slug_candidate, slug_compare=None):
|
|||
# one download at a time.
|
||||
download_in_progress = False
|
||||
|
||||
done = False
|
||||
|
||||
@app.route("/<slug_candidate>")
|
||||
def index(slug_candidate):
|
||||
|
@ -236,7 +237,7 @@ def download(slug_candidate):
|
|||
|
||||
# Deny new downloads if "Stop After First Download" is checked and there is
|
||||
# currently a download
|
||||
global stay_open, download_in_progress
|
||||
global stay_open, download_in_progress, done
|
||||
deny_download = not stay_open and download_in_progress
|
||||
if deny_download:
|
||||
r = make_response(render_template_string(open(common.get_resource_path('html/denied.html')).read()))
|
||||
|
@ -267,7 +268,7 @@ def download(slug_candidate):
|
|||
client_cancel = False
|
||||
|
||||
# Starting a new download
|
||||
global stay_open, download_in_progress
|
||||
global stay_open, download_in_progress, done
|
||||
if not stay_open:
|
||||
download_in_progress = True
|
||||
|
||||
|
|
|
@ -384,11 +384,6 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
|||
Check for messages communicated from the web app, and update the GUI accordingly.
|
||||
"""
|
||||
self.update()
|
||||
global download_in_progress
|
||||
try:
|
||||
download_in_progress
|
||||
except NameError:
|
||||
download_in_progress = False
|
||||
|
||||
# scroll to the bottom of the dl progress bar log pane
|
||||
# if a new download has been added
|
||||
|
@ -423,23 +418,21 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
|||
|
||||
elif event["type"] == web.REQUEST_PROGRESS:
|
||||
self.downloads.update_download(event["data"]["id"], event["data"]["bytes"])
|
||||
download_in_progress = True
|
||||
|
||||
# is the download complete?
|
||||
if event["data"]["bytes"] == web.zip_filesize:
|
||||
download_in_progress = False
|
||||
if self.systemTray.supportsMessages() and self.settings.get('systray_notifications'):
|
||||
self.systemTray.showMessage(strings._('systray_download_completed_title', True), strings._('systray_download_completed_message', True))
|
||||
# close on finish?
|
||||
if not web.get_stay_open():
|
||||
self.server_status.stop_server()
|
||||
self.server_status.shutdown_timeout_reset()
|
||||
self.status_bar.showMessage(strings._('closing_automatically',True))
|
||||
else:
|
||||
if self.server_status.status == self.server_status.STATUS_STOPPED:
|
||||
self.downloads.cancel_download(event["data"]["id"])
|
||||
|
||||
elif event["type"] == web.REQUEST_CANCELED:
|
||||
download_in_progress = False
|
||||
self.downloads.cancel_download(event["data"]["id"])
|
||||
if self.systemTray.supportsMessages() and self.settings.get('systray_notifications'):
|
||||
self.systemTray.showMessage(strings._('systray_download_canceled_title', True), strings._('systray_download_canceled_message', True))
|
||||
|
@ -452,7 +445,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
|||
if self.app.shutdown_timer and self.server_status.timer_enabled:
|
||||
if self.timeout > 0:
|
||||
if not self.app.shutdown_timer.is_alive():
|
||||
if not download_in_progress:
|
||||
if web.done:
|
||||
self.server_status.stop_server()
|
||||
self.status_bar.showMessage(strings._('close_on_timeout',True))
|
||||
self.server_status.shutdown_timeout_reset()
|
||||
|
|
Loading…
Reference in a new issue