mirror of
https://github.com/onionshare/onionshare.git
synced 2025-07-28 17:17:34 -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
6 changed files with 8 additions and 17 deletions
|
@ -106,7 +106,6 @@ def main(cwd=None):
|
||||||
|
|
||||||
# Create the Web object
|
# Create the Web object
|
||||||
web = Web(common, False, receive)
|
web = Web(common, False, receive)
|
||||||
web.stay_open = stay_open
|
|
||||||
|
|
||||||
# Start the Onion object
|
# Start the Onion object
|
||||||
onion = Onion(common)
|
onion = Onion(common)
|
||||||
|
@ -120,7 +119,7 @@ def main(cwd=None):
|
||||||
|
|
||||||
# Start the onionshare app
|
# Start the onionshare app
|
||||||
try:
|
try:
|
||||||
app = OnionShare(common, onion, local_only, stay_open, shutdown_timeout)
|
app = OnionShare(common, onion, local_only, shutdown_timeout)
|
||||||
app.set_stealth(stealth)
|
app.set_stealth(stealth)
|
||||||
app.choose_port()
|
app.choose_port()
|
||||||
app.start_onion_service()
|
app.start_onion_service()
|
||||||
|
@ -144,7 +143,7 @@ def main(cwd=None):
|
||||||
print('')
|
print('')
|
||||||
|
|
||||||
# Start OnionShare http service in new thread
|
# 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.daemon = True
|
||||||
t.start()
|
t.start()
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ class OnionShare(object):
|
||||||
OnionShare is the main application class. Pass in options and run
|
OnionShare is the main application class. Pass in options and run
|
||||||
start_onion_service and it will do the magic.
|
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 = common
|
||||||
|
|
||||||
self.common.log('OnionShare', '__init__')
|
self.common.log('OnionShare', '__init__')
|
||||||
|
@ -47,9 +47,6 @@ class OnionShare(object):
|
||||||
# do not use tor -- for development
|
# do not use tor -- for development
|
||||||
self.local_only = local_only
|
self.local_only = local_only
|
||||||
|
|
||||||
# automatically close when download is finished
|
|
||||||
self.stay_open = stay_open
|
|
||||||
|
|
||||||
# optionally shut down after N hours
|
# optionally shut down after N hours
|
||||||
self.shutdown_timeout = shutdown_timeout
|
self.shutdown_timeout = shutdown_timeout
|
||||||
# init timing thread
|
# init timing thread
|
||||||
|
|
|
@ -64,7 +64,6 @@ def main():
|
||||||
# Parse arguments
|
# Parse arguments
|
||||||
parser = argparse.ArgumentParser(formatter_class=lambda prog: argparse.HelpFormatter(prog,max_help_position=48))
|
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('--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('--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('--debug', action='store_true', dest='debug', help=strings._("help_debug"))
|
||||||
parser.add_argument('--filenames', metavar='filenames', nargs='+', help=strings._('help_filename'))
|
parser.add_argument('--filenames', metavar='filenames', nargs='+', help=strings._('help_filename'))
|
||||||
|
@ -79,7 +78,6 @@ def main():
|
||||||
config = args.config
|
config = args.config
|
||||||
|
|
||||||
local_only = bool(args.local_only)
|
local_only = bool(args.local_only)
|
||||||
stay_open = bool(args.stay_open)
|
|
||||||
shutdown_timeout = int(args.shutdown_timeout)
|
shutdown_timeout = int(args.shutdown_timeout)
|
||||||
debug = bool(args.debug)
|
debug = bool(args.debug)
|
||||||
|
|
||||||
|
@ -103,7 +101,7 @@ def main():
|
||||||
onion = Onion(common)
|
onion = Onion(common)
|
||||||
|
|
||||||
# Start the OnionShare app
|
# 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
|
# Launch the gui
|
||||||
gui = OnionShareGui(common, onion, qtapp, app, filenames, config, local_only)
|
gui = OnionShareGui(common, onion, qtapp, app, filenames, config, local_only)
|
||||||
|
|
|
@ -144,7 +144,7 @@ class Mode(QtWidgets.QWidget):
|
||||||
self.app.choose_port()
|
self.app.choose_port()
|
||||||
|
|
||||||
# Start http service in new thread
|
# 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.daemon = True
|
||||||
t.start()
|
t.start()
|
||||||
|
|
||||||
|
@ -161,8 +161,6 @@ class Mode(QtWidgets.QWidget):
|
||||||
self.starting_server_error.emit(e.args[0])
|
self.starting_server_error.emit(e.args[0])
|
||||||
return
|
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.common.log('Mode', 'start_server', 'Starting an onion thread')
|
||||||
self.t = OnionThread(self.common, function=start_onion_service, kwargs={'self': self})
|
self.t = OnionThread(self.common, function=start_onion_service, kwargs={'self': self})
|
||||||
self.t.daemon = True
|
self.t.daemon = True
|
||||||
|
|
|
@ -262,8 +262,8 @@ class ShareMode(Mode):
|
||||||
self.downloads_in_progress -= 1
|
self.downloads_in_progress -= 1
|
||||||
self.update_downloads_in_progress()
|
self.update_downloads_in_progress()
|
||||||
|
|
||||||
# close on finish?
|
# Close on finish?
|
||||||
if not self.web.stay_open:
|
if self.common.settings.get('close_after_first_download'):
|
||||||
self.server_status.stop_server()
|
self.server_status.stop_server()
|
||||||
self.status_bar.clearMessage()
|
self.status_bar.clearMessage()
|
||||||
self.server_status_label.setText(strings._('closing_automatically', True))
|
self.server_status_label.setText(strings._('closing_automatically', True))
|
||||||
|
|
|
@ -49,7 +49,6 @@ class TestOnionShare:
|
||||||
assert onionshare_obj.stealth is None
|
assert onionshare_obj.stealth is None
|
||||||
assert onionshare_obj.cleanup_filenames == []
|
assert onionshare_obj.cleanup_filenames == []
|
||||||
assert onionshare_obj.local_only is False
|
assert onionshare_obj.local_only is False
|
||||||
assert onionshare_obj.stay_open is False
|
|
||||||
|
|
||||||
def test_set_stealth_true(self, onionshare_obj):
|
def test_set_stealth_true(self, onionshare_obj):
|
||||||
onionshare_obj.set_stealth(True)
|
onionshare_obj.set_stealth(True)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue