diff options
author | Micah Lee <micah@micahflee.com> | 2014-06-26 14:45:18 -0400 |
---|---|---|
committer | Micah Lee <micah@micahflee.com> | 2014-06-26 14:45:18 -0400 |
commit | d0d4cebbffbba1526b7eae1b686de02c5cb9f951 (patch) | |
tree | 497ba34ea110906c9339deb979ad8dd9bd127ff8 | |
parent | 8fce3adeb563a858e07c59ef73cf4906071ab45d (diff) | |
download | onionshare-d0d4cebbffbba1526b7eae1b686de02c5cb9f951.tar.gz onionshare-d0d4cebbffbba1526b7eae1b686de02c5cb9f951.zip |
fixed bug where hidden service still closed even if "close automatically" unchecked in GUI (#58)
-rw-r--r-- | onionshare/onionshare.py | 8 | ||||
-rw-r--r-- | onionshare_gui/onionshare_gui.py | 6 | ||||
-rw-r--r-- | onionshare_gui/static/onionshare.js | 8 | ||||
-rw-r--r-- | onionshare_gui/webapp.py | 10 |
4 files changed, 29 insertions, 3 deletions
diff --git a/onionshare/onionshare.py b/onionshare/onionshare.py index 78ed7dae..c514d16a 100644 --- a/onionshare/onionshare.py +++ b/onionshare/onionshare.py @@ -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() diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index f078b224..eed72485 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -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() diff --git a/onionshare_gui/static/onionshare.js b/onionshare_gui/static/onionshare.js index c2a39f71..7dedb6af 100644 --- a/onionshare_gui/static/onionshare.js +++ b/onionshare_gui/static/onionshare.js @@ -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', diff --git a/onionshare_gui/webapp.py b/onionshare_gui/webapp.py index 42057da4..46f8b3b7 100644 --- a/onionshare_gui/webapp.py +++ b/onionshare_gui/webapp.py @@ -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 |