mirror of
https://github.com/onionshare/onionshare.git
synced 2025-06-07 06:13:03 -04:00
fixed bug where hidden service still closed even if "close automatically" unchecked in GUI (#58)
This commit is contained in:
parent
8fce3adeb5
commit
d0d4cebbff
4 changed files with 29 additions and 3 deletions
|
@ -28,6 +28,12 @@ def set_file_info(new_filename, new_filehash, new_filesize):
|
||||||
filehash = new_filehash
|
filehash = new_filehash
|
||||||
filesize = new_filesize
|
filesize = new_filesize
|
||||||
|
|
||||||
|
# automatically close
|
||||||
|
stay_open = False
|
||||||
|
def set_stay_open(new_stay_open):
|
||||||
|
global stay_open
|
||||||
|
stay_open = new_stay_open
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
# get path of onioshare directory
|
# get path of onioshare directory
|
||||||
|
@ -39,7 +45,6 @@ else:
|
||||||
strings = {}
|
strings = {}
|
||||||
slug = random_string(16)
|
slug = random_string(16)
|
||||||
download_count = 0
|
download_count = 0
|
||||||
stay_open = False
|
|
||||||
|
|
||||||
REQUEST_LOAD = 0
|
REQUEST_LOAD = 0
|
||||||
REQUEST_DOWNLOAD = 1
|
REQUEST_DOWNLOAD = 1
|
||||||
|
@ -126,6 +131,7 @@ def download():
|
||||||
# download is finished, close the server
|
# download is finished, close the server
|
||||||
global stay_open
|
global stay_open
|
||||||
if not stay_open:
|
if not stay_open:
|
||||||
|
print "Closing automatically because download finished"
|
||||||
if shutdown_func is None:
|
if shutdown_func is None:
|
||||||
raise RuntimeError('Not running with the Werkzeug Server')
|
raise RuntimeError('Not running with the Werkzeug Server')
|
||||||
shutdown_func()
|
shutdown_func()
|
||||||
|
|
|
@ -97,9 +97,11 @@ def main():
|
||||||
|
|
||||||
filename = args.filename
|
filename = args.filename
|
||||||
local_only = args.local_only
|
local_only = args.local_only
|
||||||
stay_open = args.stay_open
|
stay_open = bool(args.stay_open)
|
||||||
debug = args.debug
|
debug = args.debug
|
||||||
|
|
||||||
|
onionshare.set_stay_open(stay_open)
|
||||||
|
|
||||||
# create the onionshare icon
|
# create the onionshare icon
|
||||||
global window_icon, onionshare_gui_dir
|
global window_icon, onionshare_gui_dir
|
||||||
window_icon = QIcon("{0}/onionshare-icon.png".format(onionshare_gui_dir))
|
window_icon = QIcon("{0}/onionshare-icon.png".format(onionshare_gui_dir))
|
||||||
|
@ -130,7 +132,7 @@ def main():
|
||||||
webapp.onion_host = local_host
|
webapp.onion_host = local_host
|
||||||
webapp.qtapp = app
|
webapp.qtapp = app
|
||||||
webapp.clipboard = app.clipboard()
|
webapp.clipboard = app.clipboard()
|
||||||
webapp.stay_open = bool(stay_open)
|
webapp.stay_open = stay_open
|
||||||
|
|
||||||
# run the web app in a new thread
|
# run the web app in a new thread
|
||||||
webapp_port = onionshare.choose_port()
|
webapp_port = onionshare.choose_port()
|
||||||
|
|
|
@ -75,6 +75,14 @@ $(function(){
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$('#close-on-finish').change(function(){
|
||||||
|
if($('#close-on-finish').is(':checked')) {
|
||||||
|
$.ajax({ url: '/stay_open_false' });
|
||||||
|
} else {
|
||||||
|
$.ajax({ url: '/stay_open_true' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// initialize
|
// initialize
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/init_info',
|
url: '/init_info',
|
||||||
|
|
|
@ -85,6 +85,16 @@ def copy_url():
|
||||||
clipboard.setText(url)
|
clipboard.setText(url)
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
@app.route("/stay_open_true")
|
||||||
|
def stay_open_true():
|
||||||
|
global onionshare
|
||||||
|
onionshare.set_stay_open(True)
|
||||||
|
|
||||||
|
@app.route("/stay_open_false")
|
||||||
|
def stay_open_false():
|
||||||
|
global onionshare
|
||||||
|
onionshare.set_stay_open(False)
|
||||||
|
|
||||||
@app.route("/heartbeat")
|
@app.route("/heartbeat")
|
||||||
def check_for_requests():
|
def check_for_requests():
|
||||||
global onionshare
|
global onionshare
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue