From bb7b0cbcbd73866f934f3fad12a0909ba6fa559d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 1 Jul 2015 09:19:51 +0200 Subject: [PATCH] SWUpdate: Only use version cache from same version of OP When using the version cache only use the version cache if the OctoPrint version stored within it matches the one of the currently running instance. Otherwise we might report false positives with regards to available updates under some circumstances. --- .../plugins/softwareupdate/__init__.py | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/octoprint/plugins/softwareupdate/__init__.py b/src/octoprint/plugins/softwareupdate/__init__.py index e6972737..7cfdd2f3 100644 --- a/src/octoprint/plugins/softwareupdate/__init__.py +++ b/src/octoprint/plugins/softwareupdate/__init__.py @@ -82,9 +82,24 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin, except: self._logger.exception("Error while loading version cache from disk") else: - self._version_cache = data - self._version_cache_dirty = False - self._logger.info("Loaded version cache from disk") + try: + if "octoprint" in data and len(data["octoprint"]) == 4 and "local" in data["octoprint"][1] and "value" in data["octoprint"][1]["local"]: + data_version = data["octoprint"][1]["local"]["value"] + else: + self._logger.info("Can't determine version of OctoPrint version cache was created for, not using it") + return + + from octoprint._version import get_versions + octoprint_version = get_versions()["version"] + if data_version != octoprint_version: + self._logger.info("Version cache was created for another version of OctoPrint, not using it") + return + + self._version_cache = data + self._version_cache_dirty = False + self._logger.info("Loaded version cache from disk") + except: + self._logger.exception("Error parsing in version cache data") def _save_version_cache(self): import tempfile