fixed bug where hidden service still closed even if "close automatically" unchecked in GUI (#58)

This commit is contained in:
Micah Lee 2014-06-26 14:45:18 -04:00
parent 8fce3adeb5
commit d0d4cebbff
4 changed files with 29 additions and 3 deletions

View File

@ -28,6 +28,12 @@ def set_file_info(new_filename, new_filehash, new_filesize):
filehash = new_filehash
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__)
# get path of onioshare directory
@ -39,7 +45,6 @@ else:
strings = {}
slug = random_string(16)
download_count = 0
stay_open = False
REQUEST_LOAD = 0
REQUEST_DOWNLOAD = 1
@ -126,6 +131,7 @@ def download():
# download is finished, close the server
global stay_open
if not stay_open:
print "Closing automatically because download finished"
if shutdown_func is None:
raise RuntimeError('Not running with the Werkzeug Server')
shutdown_func()

View File

@ -97,9 +97,11 @@ def main():
filename = args.filename
local_only = args.local_only
stay_open = args.stay_open
stay_open = bool(args.stay_open)
debug = args.debug
onionshare.set_stay_open(stay_open)
# create the onionshare icon
global window_icon, 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.qtapp = app
webapp.clipboard = app.clipboard()
webapp.stay_open = bool(stay_open)
webapp.stay_open = stay_open
# run the web app in a new thread
webapp_port = onionshare.choose_port()

View File

@ -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
$.ajax({
url: '/init_info',

View File

@ -85,6 +85,16 @@ def copy_url():
clipboard.setText(url)
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")
def check_for_requests():
global onionshare