From 5d5c3d74c175c31cbde54dd74a886e5ddc191986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 9 Jun 2015 19:03:38 +0200 Subject: [PATCH] softwareupdate: re-fetch check data on plugin lifecycle events If plugins get enabled or disabled, the update check configuration needs to be refetched next time it's needed since there might have been changes to plugin implementing the check_info hook. --- src/octoprint/plugins/softwareupdate/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/octoprint/plugins/softwareupdate/__init__.py b/src/octoprint/plugins/softwareupdate/__init__.py index 5129c022..7d74ff2e 100644 --- a/src/octoprint/plugins/softwareupdate/__init__.py +++ b/src/octoprint/plugins/softwareupdate/__init__.py @@ -33,6 +33,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin, self._update_in_progress = False self._configured_checks_mutex = threading.Lock() self._configured_checks = None + self._refresh_configured_checks = False self._version_cache = dict() self._version_cache_ttl = 0 @@ -40,9 +41,15 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin, def initialize(self): self._version_cache_ttl = self._settings.get_int(["cache_ttl"]) * 60 + def refresh_checks(name, plugin): + self._refresh_configured_checks = True + self._plugin_lifecycle_manager.add_callback("enabled", refresh_checks) + self._plugin_lifecycle_manager.add_callback("disabled", refresh_checks) + def _get_configured_checks(self): with self._configured_checks_mutex: - if self._configured_checks is None: + if self._refresh_configured_checks or self._configured_checks is None: + self._refresh_configured_checks = False self._configured_checks = self._settings.get(["checks"], merged=True) update_check_hooks = self._plugin_manager.get_hooks("octoprint.plugin.softwareupdate.check_config") for name, hook in update_check_hooks.items():