fix: refresh optional CLI Apps catalogs

maintainer edit: CLI Apps settings now treats optional catalog caches as refresh candidates without blocking the initial payload, and pending polling stops when refresh is throttled instead of running indefinitely.
This commit is contained in:
chengyongru
2026-06-22 17:14:13 +08:00
committed by Xubin Ren
parent 2216405821
commit dd2cb4ca91
5 changed files with 95 additions and 13 deletions
+2 -2
View File
@@ -510,9 +510,9 @@ class CliAppManager:
apps_by_name[key] = entry
return list(apps_by_name.values()), max(updated_values) if updated_values else None
def catalog_cache_fresh(self) -> bool:
def catalog_cache_fresh(self, *, include_optional: bool = False) -> bool:
for source, _url, _raw_base, required in _CATALOG_SOURCES:
if not required:
if not required and not include_optional:
continue
data, cached_at = self._cached_registry(self._cache_path(source))
if data is None or _now() - cached_at >= self.runtime.catalog_ttl_seconds:
+4 -4
View File
@@ -34,7 +34,7 @@ def _start_catalog_refresh() -> bool:
if _catalog_refresh_running:
return True
if now - _catalog_refresh_last_started < _CATALOG_REFRESH_RETRY_SECONDS:
return True
return False
_catalog_refresh_running = True
_catalog_refresh_last_started = now
@@ -113,9 +113,9 @@ def cli_apps_payload(*, installed_only: bool = False) -> dict[str, Any]:
if installed_only:
return manager.installed_payload()
payload = manager.payload(cache_only=True)
refresh_pending = not manager.catalog_cache_fresh()
if refresh_pending:
_start_catalog_refresh()
refresh_pending = False
if not manager.catalog_cache_fresh(include_optional=True):
refresh_pending = _start_catalog_refresh()
if not payload["apps"]:
installed = manager.installed_payload()
if installed["apps"]: