INNER CODE UNIT · Python
_is_newer_version
Duelion/homebox-companion · server/app.py:68
def _is_newer_version(latest: str, current: str) -> bool:
"""Check if latest version is newer than current version."""
try:
latest_parts = _parse_version(latest)
current_parts = _parse_version(current)
return latest_parts > current_parts
except (ValueError, AttributeError):
return False
async def _get_latest_github_version() -> str | None:
"""Fetch the latest release version from GitHub with caching and proper error handling.
Implements both positive caching (1 hour for successful checks) and negative caching
(5 minutes for failed checks) to prevent hammering the GitHub API during outages.
Uses double-checked locking to minimize lock hold time: first checks cache without
lock, then acquires lock only when refresh is needed and re-checks to avoid