refactor(download): remove ProviderCore/download.py, move sanitize_filename to SYS.utils, replace callers to use API.HTTP.HTTPClient

This commit is contained in:
2026-01-06 01:38:59 -08:00
parent 3b363dd536
commit 41c11d39fd
38 changed files with 2640 additions and 526 deletions

View File

@@ -374,3 +374,61 @@ class Store:
return bool(ok) if ok is not None else True
except Exception:
return False
def list_configured_backend_names(config: Optional[Dict[str, Any]]) -> list[str]:
"""Return backend instance names present in the provided config WITHOUT instantiating backends.
This is a lightweight helper for CLI usage where we only need to know if a
configured backend exists (e.g., to distinguish a store name from a filesystem path)
without triggering backend initialization (which may perform network calls).
Behaviour:
- For each configured store type, returns the per-instance NAME override (case-insensitive)
when present, otherwise the instance key.
- Includes a 'temp' alias when a folder backend points to the configured 'temp' path.
"""
try:
store_cfg = (config or {}).get("store") or {}
if not isinstance(store_cfg, dict):
return []
names: list[str] = []
for raw_store_type, instances in store_cfg.items():
if not isinstance(instances, dict):
continue
for instance_name, instance_config in instances.items():
if isinstance(instance_config, dict):
override_name = _get_case_insensitive(dict(instance_config), "NAME")
if override_name:
names.append(str(override_name))
else:
names.append(str(instance_name))
else:
names.append(str(instance_name))
# Best-effort: alias 'temp' when a folder backend points at config['temp']
try:
temp_value = (config or {}).get("temp")
if temp_value:
temp_path = str(Path(str(temp_value)).expanduser().resolve())
for raw_store_type, instances in store_cfg.items():
if not isinstance(instances, dict):
continue
if _normalize_store_type(str(raw_store_type)) != "folder":
continue
for instance_name, instance_config in instances.items():
if not isinstance(instance_config, dict):
continue
path_value = instance_config.get("PATH") or instance_config.get("path")
if not path_value:
continue
if str(Path(str(path_value)).expanduser().resolve()) == temp_path:
if "temp" not in names:
names.append("temp")
except Exception:
pass
return sorted(set(names))
except Exception:
return []