From b743cc61c85a71c023a33258dfeeceeee2ba7f50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Sat, 13 Nov 2021 13:15:08 +0100 Subject: [PATCH] Fix issue with showingf correct version after restore (#2283) --- .../hacs/helpers/properties/pending_update.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/custom_components/hacs/helpers/properties/pending_update.py b/custom_components/hacs/helpers/properties/pending_update.py index 083930e868e..82e66ab2167 100644 --- a/custom_components/hacs/helpers/properties/pending_update.py +++ b/custom_components/hacs/helpers/properties/pending_update.py @@ -1,6 +1,8 @@ # pylint: disable=missing-class-docstring,missing-module-docstring,missing-function-docstring,no-member from abc import ABC +from awesomeversion import AwesomeVersion, AwesomeVersionException + class RepositoryPropertyPendingUpdate(ABC): @property @@ -13,8 +15,17 @@ def pending_update(self) -> bool: if self.data.installed_commit != self.data.last_commit: return True return False - if self.display_installed_version != self.display_available_version: - return True + if self.display_version_or_commit == "commit": + if self.display_installed_version != self.display_available_version: + return True + else: + try: + return AwesomeVersion(self.display_available_version) > AwesomeVersion( + self.display_installed_version + ) + except AwesomeVersionException: + # Assume pending_update on failure + return True return False @property