From 352c0d03862f97efdcca5b289f6012c5d117f070 Mon Sep 17 00:00:00 2001 From: AJ Jordan Date: Wed, 3 Jul 2019 01:46:39 -0700 Subject: [PATCH] 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. --- qubesmanager/global_settings.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/qubesmanager/global_settings.py b/qubesmanager/global_settings.py index 2fb8867..ee7767c 100644 --- a/qubesmanager/global_settings.py +++ b/qubesmanager/global_settings.py @@ -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',