Only make qrexec calls when necessary

This helps in situations where the qrexec calls are forbidden; it also
prevents settings from being unintentionally changed and gives a
noticeable performance boost when the "OK" button is clicked.
This commit is contained in:
AJ Jordan 2019-07-03 01:46:39 -07:00
parent e0919beec1
commit 352c0d0386
No known key found for this signature in database
GPG Key ID: 26794034633DBBC0

View File

@ -267,7 +267,7 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings,
self.enable_updates_all.clicked.connect(self.__enable_updates_all)
self.disable_updates_all.clicked.connect(self.__disable_updates_all)
repos = dict()
self.repos = repos = dict()
for i in _run_qrexec_repo('qubes.repos.List').split('\n'):
lst = i.split('\0')
# Keyed by repo name
@ -338,9 +338,13 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings,
self.qvm_collection.check_updates_vm = self.updates_vm.isChecked()
def _manage_repos(self, repolist, action):
for i in repolist:
for name in repolist:
if self.repos[name]['enabled'] and action == 'Enable' or \
not self.repos[name]['enabled'] and action == 'Disable':
continue
try:
result = _run_qrexec_repo('qubes.repos.' + action, i)
result = _run_qrexec_repo('qubes.repos.' + action, name)
if result != 'ok\n':
raise RuntimeError(
'qrexec call stdout did not contain "ok" as expected',