mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-29 20:45:11 +00:00
fix(api): cache the health update check and fix a remote-session test fixture
This commit is contained in:
@@ -223,7 +223,7 @@ async def health(request: web.Request) -> web.Response:
|
||||
nullable: true
|
||||
"""
|
||||
try:
|
||||
latest_version = await UpdateChecker.check_for_updates(__version__)
|
||||
latest_version = await asyncio.to_thread(UpdateChecker.check_for_updates_sync, __version__)
|
||||
update_info = {
|
||||
"update_available": latest_version is not None,
|
||||
"current_version": __version__,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import time
|
||||
from pathlib import Path
|
||||
@@ -195,31 +194,6 @@ class UpdateChecker:
|
||||
except (ValueError, AttributeError):
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
async def check_for_updates(cls, current_version: str) -> Optional[str]:
|
||||
"""
|
||||
Examine GitHub for a newer version.
|
||||
|
||||
Args:
|
||||
current_version: The current version string (e.g., "1.1.0")
|
||||
|
||||
Returns:
|
||||
The latest version string if an update is available, None otherwise
|
||||
"""
|
||||
if not cls.is_valid_version(current_version):
|
||||
return None
|
||||
|
||||
try:
|
||||
latest_version = await asyncio.to_thread(cls.fetch_latest_version)
|
||||
|
||||
if latest_version and cls.compare_versions(current_version, latest_version):
|
||||
return latest_version
|
||||
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
def get_cached_update_info(cls, current_version: str) -> Optional[str]:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user