k
This commit is contained in:
@@ -202,7 +202,8 @@ class SharedArgs:
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def get_store_choices(config: Optional[Dict[str, Any]] = None) -> List[str]:
|
||||
@staticmethod
|
||||
def get_store_choices(config: Optional[Dict[str, Any]] = None, force: bool = False) -> List[str]:
|
||||
"""Get list of available store backend names.
|
||||
|
||||
This method returns the cached list of available backends from the most
|
||||
@@ -210,7 +211,8 @@ class SharedArgs:
|
||||
Users must restart to refresh the list if stores are enabled/disabled.
|
||||
|
||||
Args:
|
||||
config: Ignored (kept for compatibility); uses cached startup result.
|
||||
config: Optional config dict. Used if force=True or no cache exists.
|
||||
force: If True, force a fresh check of the backends.
|
||||
|
||||
Returns:
|
||||
List of backend names (e.g., ['default', 'test', 'home', 'work'])
|
||||
@@ -219,23 +221,13 @@ class SharedArgs:
|
||||
Example:
|
||||
SharedArgs.STORE.choices = SharedArgs.get_store_choices(config)
|
||||
"""
|
||||
# Use the cached startup check result if available
|
||||
if hasattr(SharedArgs, "_cached_available_stores"):
|
||||
# Use the cached startup check result if available (unless force=True)
|
||||
if not force and hasattr(SharedArgs, "_cached_available_stores"):
|
||||
return SharedArgs._cached_available_stores or []
|
||||
|
||||
# Fallback to configured names if cache doesn't exist yet
|
||||
# (This shouldn't happen in normal operation, but provides a safe fallback)
|
||||
try:
|
||||
from Store.registry import list_configured_backend_names
|
||||
if config is None:
|
||||
try:
|
||||
from SYS.config import load_config
|
||||
config = load_config()
|
||||
except Exception:
|
||||
return []
|
||||
return list_configured_backend_names(config) or []
|
||||
except Exception:
|
||||
return []
|
||||
# Refresh the cache
|
||||
SharedArgs._refresh_store_choices_cache(config)
|
||||
return SharedArgs._cached_available_stores or []
|
||||
|
||||
@staticmethod
|
||||
def _refresh_store_choices_cache(config: Optional[Dict[str, Any]] = None) -> None:
|
||||
|
||||
Reference in New Issue
Block a user