mirror of
https://github.com/onionshare/onionshare.git
synced 2025-06-07 14:23:01 -04:00
#535 do the forced update check via a (non-blocking) QThread
This commit is contained in:
parent
95c8c0fb81
commit
70a624c331
2 changed files with 25 additions and 21 deletions
|
@ -557,31 +557,34 @@ class SettingsDialog(QtWidgets.QDialog):
|
||||||
self._disable_buttons()
|
self._disable_buttons()
|
||||||
self.qtapp.processEvents()
|
self.qtapp.processEvents()
|
||||||
|
|
||||||
|
def update_timestamp():
|
||||||
|
# Update the last checked label
|
||||||
|
settings = Settings(self.config)
|
||||||
|
settings.load()
|
||||||
|
autoupdate_timestamp = settings.get('autoupdate_timestamp')
|
||||||
|
self._update_autoupdate_timestamp(autoupdate_timestamp)
|
||||||
|
|
||||||
# Check for updates
|
# Check for updates
|
||||||
def update_available(update_url, installed_version, latest_version):
|
def update_available(update_url, installed_version, latest_version):
|
||||||
Alert(strings._("update_available", True).format(update_url, installed_version, latest_version))
|
Alert(strings._("update_available", True).format(update_url, installed_version, latest_version))
|
||||||
|
forced_update_thread.quit()
|
||||||
|
# Enable buttons
|
||||||
|
self._enable_buttons()
|
||||||
|
# Update timestamp
|
||||||
|
update_timestamp()
|
||||||
|
|
||||||
def update_not_available():
|
def update_not_available():
|
||||||
Alert(strings._('update_not_available', True))
|
Alert(strings._('update_not_available', True))
|
||||||
|
forced_update_thread.quit()
|
||||||
|
# Enable buttons
|
||||||
|
self._enable_buttons()
|
||||||
|
# Update timestamp
|
||||||
|
update_timestamp()
|
||||||
|
|
||||||
u = UpdateChecker(self.onion)
|
forced_update_thread = UpdateThread(self.onion, self.config, force=True)
|
||||||
u.update_available.connect(update_available)
|
forced_update_thread.update_available.connect(update_available)
|
||||||
u.update_not_available.connect(update_not_available)
|
forced_update_thread.update_not_available.connect(update_not_available)
|
||||||
|
forced_update_thread.start()
|
||||||
try:
|
|
||||||
u.check(force=True)
|
|
||||||
except UpdateCheckerCheckError:
|
|
||||||
Alert(strings._('update_error_check_error', True), QtWidgets.QMessageBox.Warning)
|
|
||||||
except UpdateCheckerInvalidLatestVersion as e:
|
|
||||||
Alert(strings._('update_error_invalid_latest_version', True).format(e.latest_version), QtWidgets.QMessageBox.Warning)
|
|
||||||
|
|
||||||
# Enable buttons
|
|
||||||
self._enable_buttons()
|
|
||||||
|
|
||||||
# Update the last checked label
|
|
||||||
settings = Settings(self.config)
|
|
||||||
settings.load()
|
|
||||||
autoupdate_timestamp = settings.get('autoupdate_timestamp')
|
|
||||||
self._update_autoupdate_timestamp(autoupdate_timestamp)
|
|
||||||
|
|
||||||
def save_clicked(self):
|
def save_clicked(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -149,11 +149,12 @@ class UpdateThread(QtCore.QThread):
|
||||||
update_available = QtCore.pyqtSignal(str, str, str)
|
update_available = QtCore.pyqtSignal(str, str, str)
|
||||||
update_not_available = QtCore.pyqtSignal()
|
update_not_available = QtCore.pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, onion, config=False):
|
def __init__(self, onion, config=False, force=False):
|
||||||
super(UpdateThread, self).__init__()
|
super(UpdateThread, self).__init__()
|
||||||
common.log('UpdateThread', '__init__')
|
common.log('UpdateThread', '__init__')
|
||||||
self.onion = onion
|
self.onion = onion
|
||||||
self.config = config
|
self.config = config
|
||||||
|
self.force = force
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
common.log('UpdateThread', 'run')
|
common.log('UpdateThread', 'run')
|
||||||
|
@ -163,7 +164,7 @@ class UpdateThread(QtCore.QThread):
|
||||||
u.update_not_available.connect(self._update_not_available)
|
u.update_not_available.connect(self._update_not_available)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
u.check(config=self.config)
|
u.check(config=self.config,force=self.force)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# If update check fails, silently ignore
|
# If update check fails, silently ignore
|
||||||
common.log('UpdateThread', 'run', '{}'.format(e))
|
common.log('UpdateThread', 'run', '{}'.format(e))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue