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:
@@ -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:
|
||||
|
||||
@@ -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"]:
|
||||
|
||||
Reference in New Issue
Block a user