Try exact match first for update state (#69335)
- Exact matches are much cheaper than creating an AwesomeVersion and calling the __gt__ method, and since most of the time the result is expected to be off, we want to optimize for this case
This commit is contained in:
parent
2cf3057ff1
commit
1a9420dda0
1 changed files with 4 additions and 2 deletions
|
@ -327,13 +327,15 @@ class UpdateEntity(RestoreEntity):
|
|||
|
||||
if latest_version == self.__skipped_version:
|
||||
return STATE_OFF
|
||||
if latest_version == installed_version:
|
||||
return STATE_OFF
|
||||
|
||||
try:
|
||||
newer = AwesomeVersion(latest_version) > installed_version
|
||||
return STATE_ON if newer else STATE_OFF
|
||||
except AwesomeVersionCompareException:
|
||||
# Can't compare versions, fallback to exact match
|
||||
return STATE_OFF if latest_version == installed_version else STATE_ON
|
||||
# Can't compare versions, already tried exact match
|
||||
return STATE_ON
|
||||
|
||||
@final
|
||||
@property
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue