f
This commit is contained in:
@@ -467,7 +467,7 @@ def get_local_storage_path(config: Dict[str, Any]) -> Optional[Path]:
|
|||||||
"""Get local storage path from config.
|
"""Get local storage path from config.
|
||||||
|
|
||||||
Supports multiple formats:
|
Supports multiple formats:
|
||||||
- New: config["store"]["folder"]["*"]["path"] (picks first folder store if 'default' is missing)
|
- New: config["store"]["folder"]["any_name"]["path"]
|
||||||
- Old: config["storage"]["local"]["path"]
|
- Old: config["storage"]["local"]["path"]
|
||||||
- Old: config["Local"]["path"]
|
- Old: config["Local"]["path"]
|
||||||
|
|
||||||
@@ -477,19 +477,11 @@ def get_local_storage_path(config: Dict[str, Any]) -> Optional[Path]:
|
|||||||
Returns:
|
Returns:
|
||||||
Path object if found, None otherwise
|
Path object if found, None otherwise
|
||||||
"""
|
"""
|
||||||
# Try new format first: store.folder.default.path
|
# Try new format: iterate all folder stores and use the first valid path found.
|
||||||
store = config.get("store", {})
|
store = config.get("store", {})
|
||||||
if isinstance(store, dict):
|
if isinstance(store, dict):
|
||||||
folder_config = store.get("folder", {})
|
folder_config = store.get("folder", {})
|
||||||
if isinstance(folder_config, dict):
|
if isinstance(folder_config, dict):
|
||||||
# 1. Try "default" specifically
|
|
||||||
default_config = folder_config.get("default", {})
|
|
||||||
if isinstance(default_config, dict):
|
|
||||||
path_str = default_config.get("path")
|
|
||||||
if path_str:
|
|
||||||
return expand_path(path_str)
|
|
||||||
|
|
||||||
# 2. If no "default", pick the first one that has a path
|
|
||||||
for name, inst_cfg in folder_config.items():
|
for name, inst_cfg in folder_config.items():
|
||||||
if isinstance(inst_cfg, dict):
|
if isinstance(inst_cfg, dict):
|
||||||
p = inst_cfg.get("path") or inst_cfg.get("PATH")
|
p = inst_cfg.get("path") or inst_cfg.get("PATH")
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ CMDLET = Cmdlet(
|
|||||||
detail=[
|
detail=[
|
||||||
"Use a registered provider to build a table and optionally run another cmdlet with selection args.",
|
"Use a registered provider to build a table and optionally run another cmdlet with selection args.",
|
||||||
"Emits pipeline-friendly dicts enriched with `_selection_args` so you can pipe into `select` and other cmdlets.",
|
"Emits pipeline-friendly dicts enriched with `_selection_args` so you can pipe into `select` and other cmdlets.",
|
||||||
"Example: provider-table -provider example -sample | select -select 1 | add-file -store default",
|
"Example: provider-table -provider example -sample | select -select 1 | add-file -store my_store",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -573,15 +573,26 @@ class search_file(Cmdlet):
|
|||||||
|
|
||||||
library_root = get_local_storage_path(config or {})
|
library_root = get_local_storage_path(config or {})
|
||||||
if not library_root:
|
if not library_root:
|
||||||
# Fallback for search-file: if no global "default" path is found,
|
# Fallback for search-file: if no global folder path is found,
|
||||||
# try to use the specific backend mentioned in -store or the first available folder backend.
|
# try to use the specific backend mentioned in -store or the first available folder backend.
|
||||||
backend_name = storage_backend or "default"
|
if storage_backend:
|
||||||
try:
|
try:
|
||||||
backend = storage_registry[backend_name]
|
backend = storage_registry[storage_backend]
|
||||||
if backend and type(backend).__name__ == "Folder":
|
if backend and type(backend).__name__ == "Folder":
|
||||||
library_root = expand_path(getattr(backend, "_location", None))
|
library_root = expand_path(getattr(backend, "_location", None))
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
# Try all backends until we find a Folder one
|
||||||
|
for name in storage_registry.list_backends():
|
||||||
|
try:
|
||||||
|
backend = storage_registry[name]
|
||||||
|
if type(backend).__name__ == "Folder":
|
||||||
|
library_root = expand_path(getattr(backend, "_location", None))
|
||||||
|
if library_root:
|
||||||
|
break
|
||||||
|
except Exception:
|
||||||
|
continue
|
||||||
|
|
||||||
if not library_root:
|
if not library_root:
|
||||||
log("No library root configured. Use the .config command to set up storage.", file=sys.stderr)
|
log("No library root configured. Use the .config command to set up storage.", file=sys.stderr)
|
||||||
|
|||||||
Reference in New Issue
Block a user