f
This commit is contained in:
@@ -164,45 +164,6 @@ class Store:
|
||||
str] = {}
|
||||
self._load_backends()
|
||||
|
||||
def _maybe_register_temp_alias(
|
||||
self,
|
||||
store_type: str,
|
||||
backend_name: str,
|
||||
kwargs: Dict[str,
|
||||
Any],
|
||||
backend: BaseStore
|
||||
) -> None:
|
||||
"""If a folder backend points at config['temp'], also expose it as the 'temp' backend.
|
||||
|
||||
This keeps config compatibility (e.g. existing 'default') while presenting the temp
|
||||
directory under a clearer name.
|
||||
"""
|
||||
try:
|
||||
if _normalize_store_type(store_type) != "folder":
|
||||
return
|
||||
temp_value = self._config.get("temp")
|
||||
if not temp_value:
|
||||
return
|
||||
path_value = kwargs.get("PATH") or kwargs.get("path")
|
||||
if not path_value:
|
||||
return
|
||||
|
||||
temp_path = expand_path(temp_value).resolve()
|
||||
backend_path = expand_path(path_value).resolve()
|
||||
if backend_path != temp_path:
|
||||
return
|
||||
|
||||
# If the user already has a dedicated temp backend, do nothing.
|
||||
if "temp" in self._backends:
|
||||
return
|
||||
|
||||
# Keep original name working, but add an alias.
|
||||
if backend_name != "temp":
|
||||
self._backends["temp"] = backend
|
||||
self._backend_types["temp"] = store_type
|
||||
except Exception:
|
||||
return
|
||||
|
||||
def _load_backends(self) -> None:
|
||||
store_cfg = self._config.get("store")
|
||||
if not isinstance(store_cfg, dict):
|
||||
@@ -256,14 +217,6 @@ class Store:
|
||||
backend_name = str(kwargs.get("NAME") or instance_name)
|
||||
self._backends[backend_name] = backend
|
||||
self._backend_types[backend_name] = store_type
|
||||
|
||||
# If this is the configured temp directory, also alias it as 'temp'.
|
||||
self._maybe_register_temp_alias(
|
||||
store_type,
|
||||
backend_name,
|
||||
kwargs,
|
||||
backend
|
||||
)
|
||||
except Exception as exc:
|
||||
err_text = str(exc)
|
||||
self._backend_errors[str(instance_name)] = err_text
|
||||
@@ -447,7 +400,6 @@ def list_configured_backend_names(config: Optional[Dict[str, Any]]) -> list[str]
|
||||
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 {}
|
||||
@@ -468,28 +420,6 @@ def list_configured_backend_names(config: Optional[Dict[str, Any]]) -> list[str]
|
||||
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(expand_path(temp_value).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(expand_path(path_value).resolve()) == temp_path:
|
||||
if "temp" not in names:
|
||||
names.append("temp")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return sorted(set(names))
|
||||
except Exception:
|
||||
return []
|
||||
|
||||
Reference in New Issue
Block a user