mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-26 11:13:00 -03:00
Stop worrying about common.gui.config in settings and update check
This commit is contained in:
parent
b815b0e9e2
commit
4b416141c2
3 changed files with 12 additions and 15 deletions
|
@ -187,8 +187,8 @@ class Onion(object):
|
||||||
|
|
||||||
def connect(
|
def connect(
|
||||||
self,
|
self,
|
||||||
custom_settings=False,
|
custom_settings=None,
|
||||||
config=False,
|
config=None,
|
||||||
tor_status_update_func=None,
|
tor_status_update_func=None,
|
||||||
connect_timeout=120,
|
connect_timeout=120,
|
||||||
local_only=False,
|
local_only=False,
|
||||||
|
|
|
@ -716,7 +716,7 @@ class SettingsDialog(QtWidgets.QDialog):
|
||||||
|
|
||||||
def reload_settings(self):
|
def reload_settings(self):
|
||||||
# Load settings, and fill them in
|
# Load settings, and fill them in
|
||||||
self.old_settings = Settings(self.common, self.common.gui.config)
|
self.old_settings = Settings(self.common)
|
||||||
self.old_settings.load()
|
self.old_settings.load()
|
||||||
|
|
||||||
close_after_first_download = self.old_settings.get("close_after_first_download")
|
close_after_first_download = self.old_settings.get("close_after_first_download")
|
||||||
|
@ -1063,7 +1063,6 @@ class SettingsDialog(QtWidgets.QDialog):
|
||||||
onion = Onion(self.common)
|
onion = Onion(self.common)
|
||||||
onion.connect(
|
onion.connect(
|
||||||
custom_settings=settings,
|
custom_settings=settings,
|
||||||
config=self.common.gui.config,
|
|
||||||
tor_status_update_func=tor_status_update_func,
|
tor_status_update_func=tor_status_update_func,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1109,7 +1108,7 @@ class SettingsDialog(QtWidgets.QDialog):
|
||||||
|
|
||||||
def update_timestamp():
|
def update_timestamp():
|
||||||
# Update the last checked label
|
# Update the last checked label
|
||||||
settings = Settings(self.common, self.common.gui.config)
|
settings = Settings(self.common)
|
||||||
settings.load()
|
settings.load()
|
||||||
autoupdate_timestamp = settings.get("autoupdate_timestamp")
|
autoupdate_timestamp = settings.get("autoupdate_timestamp")
|
||||||
self._update_autoupdate_timestamp(autoupdate_timestamp)
|
self._update_autoupdate_timestamp(autoupdate_timestamp)
|
||||||
|
@ -1152,7 +1151,7 @@ class SettingsDialog(QtWidgets.QDialog):
|
||||||
close_forced_update_thread()
|
close_forced_update_thread()
|
||||||
|
|
||||||
forced_update_thread = UpdateThread(
|
forced_update_thread = UpdateThread(
|
||||||
self.common, self.onion, self.common.gui.config, force=True
|
self.common, self.onion, force=True
|
||||||
)
|
)
|
||||||
forced_update_thread.update_available.connect(update_available)
|
forced_update_thread.update_available.connect(update_available)
|
||||||
forced_update_thread.update_not_available.connect(update_not_available)
|
forced_update_thread.update_not_available.connect(update_not_available)
|
||||||
|
@ -1294,7 +1293,7 @@ class SettingsDialog(QtWidgets.QDialog):
|
||||||
Return a Settings object that's full of values from the settings dialog.
|
Return a Settings object that's full of values from the settings dialog.
|
||||||
"""
|
"""
|
||||||
self.common.log("SettingsDialog", "settings_from_fields")
|
self.common.log("SettingsDialog", "settings_from_fields")
|
||||||
settings = Settings(self.common, self.common.gui.config)
|
settings = Settings(self.common)
|
||||||
settings.load() # To get the last update timestamp
|
settings.load() # To get the last update timestamp
|
||||||
|
|
||||||
settings.set(
|
settings.set(
|
||||||
|
|
|
@ -61,19 +61,18 @@ class UpdateChecker(QtCore.QObject):
|
||||||
update_error = QtCore.pyqtSignal()
|
update_error = QtCore.pyqtSignal()
|
||||||
update_invalid_version = QtCore.pyqtSignal(str)
|
update_invalid_version = QtCore.pyqtSignal(str)
|
||||||
|
|
||||||
def __init__(self, common, onion, config=False):
|
def __init__(self, common, onion):
|
||||||
super(UpdateChecker, self).__init__()
|
super(UpdateChecker, self).__init__()
|
||||||
|
|
||||||
self.common = common
|
self.common = common
|
||||||
|
|
||||||
self.common.log("UpdateChecker", "__init__")
|
self.common.log("UpdateChecker", "__init__")
|
||||||
self.onion = onion
|
self.onion = onion
|
||||||
self.config = config
|
|
||||||
|
|
||||||
def check(self, force=False, config=False):
|
def check(self, force=False):
|
||||||
self.common.log("UpdateChecker", "check", f"force={force}")
|
self.common.log("UpdateChecker", "check", f"force={force}")
|
||||||
# Load the settings
|
# Load the settings
|
||||||
settings = Settings(self.common, config)
|
settings = Settings(self.common)
|
||||||
settings.load()
|
settings.load()
|
||||||
|
|
||||||
# If force=True, then definitely check
|
# If force=True, then definitely check
|
||||||
|
@ -188,27 +187,26 @@ class UpdateThread(QtCore.QThread):
|
||||||
update_error = QtCore.pyqtSignal()
|
update_error = QtCore.pyqtSignal()
|
||||||
update_invalid_version = QtCore.pyqtSignal(str)
|
update_invalid_version = QtCore.pyqtSignal(str)
|
||||||
|
|
||||||
def __init__(self, common, onion, config=False, force=False):
|
def __init__(self, common, onion, force=False):
|
||||||
super(UpdateThread, self).__init__()
|
super(UpdateThread, self).__init__()
|
||||||
|
|
||||||
self.common = common
|
self.common = common
|
||||||
|
|
||||||
self.common.log("UpdateThread", "__init__")
|
self.common.log("UpdateThread", "__init__")
|
||||||
self.onion = onion
|
self.onion = onion
|
||||||
self.config = config
|
|
||||||
self.force = force
|
self.force = force
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.common.log("UpdateThread", "run")
|
self.common.log("UpdateThread", "run")
|
||||||
|
|
||||||
u = UpdateChecker(self.common, self.onion, self.config)
|
u = UpdateChecker(self.common, self.onion)
|
||||||
u.update_available.connect(self._update_available)
|
u.update_available.connect(self._update_available)
|
||||||
u.update_not_available.connect(self._update_not_available)
|
u.update_not_available.connect(self._update_not_available)
|
||||||
u.update_error.connect(self._update_error)
|
u.update_error.connect(self._update_error)
|
||||||
u.update_invalid_version.connect(self._update_invalid_version)
|
u.update_invalid_version.connect(self._update_invalid_version)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
u.check(config=self.config, force=self.force)
|
u.check(force=self.force)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# If update check fails, silently ignore
|
# If update check fails, silently ignore
|
||||||
self.common.log("UpdateThread", "run", str(e))
|
self.common.log("UpdateThread", "run", str(e))
|
||||||
|
|
Loading…
Add table
Reference in a new issue