diff --git a/onionshare/__init__.py b/onionshare/__init__.py index e2374c5f..86f03b84 100644 --- a/onionshare/__init__.py +++ b/onionshare/__init__.py @@ -106,7 +106,6 @@ def main(cwd=None): # Create the Web object web = Web(common, False, receive) - web.stay_open = stay_open # Start the Onion object onion = Onion(common) @@ -120,7 +119,7 @@ def main(cwd=None): # Start the onionshare app try: - app = OnionShare(common, onion, local_only, stay_open, shutdown_timeout) + app = OnionShare(common, onion, local_only, shutdown_timeout) app.set_stealth(stealth) app.choose_port() app.start_onion_service() @@ -144,7 +143,7 @@ def main(cwd=None): print('') # Start OnionShare http service in new thread - t = threading.Thread(target=web.start, args=(app.port, app.stay_open, common.settings.get('slug'))) + t = threading.Thread(target=web.start, args=(app.port, stay_open, common.settings.get('slug'))) t.daemon = True t.start() diff --git a/onionshare/onionshare.py b/onionshare/onionshare.py index e7306510..09d32cb2 100644 --- a/onionshare/onionshare.py +++ b/onionshare/onionshare.py @@ -28,7 +28,7 @@ class OnionShare(object): OnionShare is the main application class. Pass in options and run start_onion_service and it will do the magic. """ - def __init__(self, common, onion, local_only=False, stay_open=False, shutdown_timeout=0): + def __init__(self, common, onion, local_only=False, shutdown_timeout=0): self.common = common self.common.log('OnionShare', '__init__') @@ -47,9 +47,6 @@ class OnionShare(object): # do not use tor -- for development self.local_only = local_only - # automatically close when download is finished - self.stay_open = stay_open - # optionally shut down after N hours self.shutdown_timeout = shutdown_timeout # init timing thread @@ -60,7 +57,7 @@ class OnionShare(object): self.stealth = stealth self.onion.stealth = stealth - + def choose_port(self): """ Choose a random port. diff --git a/onionshare_gui/__init__.py b/onionshare_gui/__init__.py index a46fe009..c3df057b 100644 --- a/onionshare_gui/__init__.py +++ b/onionshare_gui/__init__.py @@ -64,7 +64,6 @@ def main(): # Parse arguments parser = argparse.ArgumentParser(formatter_class=lambda prog: argparse.HelpFormatter(prog,max_help_position=48)) parser.add_argument('--local-only', action='store_true', dest='local_only', help=strings._("help_local_only")) - parser.add_argument('--stay-open', action='store_true', dest='stay_open', help=strings._("help_stay_open")) parser.add_argument('--shutdown-timeout', metavar='', dest='shutdown_timeout', default=0, help=strings._("help_shutdown_timeout")) parser.add_argument('--debug', action='store_true', dest='debug', help=strings._("help_debug")) parser.add_argument('--filenames', metavar='filenames', nargs='+', help=strings._('help_filename')) @@ -79,7 +78,6 @@ def main(): config = args.config local_only = bool(args.local_only) - stay_open = bool(args.stay_open) shutdown_timeout = int(args.shutdown_timeout) debug = bool(args.debug) @@ -103,7 +101,7 @@ def main(): onion = Onion(common) # Start the OnionShare app - app = OnionShare(common, onion, local_only, stay_open, shutdown_timeout) + app = OnionShare(common, onion, local_only, shutdown_timeout) # Launch the gui gui = OnionShareGui(common, onion, qtapp, app, filenames, config, local_only) diff --git a/onionshare_gui/mode.py b/onionshare_gui/mode.py index b6910375..d425341e 100644 --- a/onionshare_gui/mode.py +++ b/onionshare_gui/mode.py @@ -144,7 +144,7 @@ class Mode(QtWidgets.QWidget): self.app.choose_port() # Start http service in new thread - t = threading.Thread(target=self.web.start, args=(self.app.port, self.app.stay_open, self.common.settings.get('slug'))) + t = threading.Thread(target=self.web.start, args=(self.app.port, not self.common.settings.get('close_after_first_download'), self.common.settings.get('slug'))) t.daemon = True t.start() @@ -161,8 +161,6 @@ class Mode(QtWidgets.QWidget): self.starting_server_error.emit(e.args[0]) return - self.app.stay_open = not self.common.settings.get('close_after_first_download') - self.common.log('Mode', 'start_server', 'Starting an onion thread') self.t = OnionThread(self.common, function=start_onion_service, kwargs={'self': self}) self.t.daemon = True diff --git a/onionshare_gui/share_mode/__init__.py b/onionshare_gui/share_mode/__init__.py index 9c98554d..91046ad9 100644 --- a/onionshare_gui/share_mode/__init__.py +++ b/onionshare_gui/share_mode/__init__.py @@ -262,8 +262,8 @@ class ShareMode(Mode): self.downloads_in_progress -= 1 self.update_downloads_in_progress() - # close on finish? - if not self.web.stay_open: + # Close on finish? + if self.common.settings.get('close_after_first_download'): self.server_status.stop_server() self.status_bar.clearMessage() self.server_status_label.setText(strings._('closing_automatically', True)) diff --git a/test/test_onionshare.py b/test/test_onionshare.py index 19b488df..7592a777 100644 --- a/test/test_onionshare.py +++ b/test/test_onionshare.py @@ -49,7 +49,6 @@ class TestOnionShare: assert onionshare_obj.stealth is None assert onionshare_obj.cleanup_filenames == [] assert onionshare_obj.local_only is False - assert onionshare_obj.stay_open is False def test_set_stealth_true(self, onionshare_obj): onionshare_obj.set_stealth(True)