mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
Fix stay_open regression bug. Before, it was closing automatically even when the setting wasn't set. Also, remove the --stay-open option from the GUI, since GUI settings are set in the settings dialog not cli args
This commit is contained in:
parent
dcea459580
commit
e32e850548
@ -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()
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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='<int>', 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)
|
||||
|
@ -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
|
||||
|
@ -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))
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user