d
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"]["default"]["path"]
|
- New: config["store"]["folder"]["*"]["path"] (picks first folder store if 'default' is missing)
|
||||||
- Old: config["storage"]["local"]["path"]
|
- Old: config["storage"]["local"]["path"]
|
||||||
- Old: config["Local"]["path"]
|
- Old: config["Local"]["path"]
|
||||||
|
|
||||||
@@ -482,12 +482,20 @@ def get_local_storage_path(config: Dict[str, Any]) -> Optional[Path]:
|
|||||||
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", {})
|
default_config = folder_config.get("default", {})
|
||||||
if isinstance(default_config, dict):
|
if isinstance(default_config, dict):
|
||||||
path_str = default_config.get("path")
|
path_str = default_config.get("path")
|
||||||
if path_str:
|
if path_str:
|
||||||
return expand_path(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():
|
||||||
|
if isinstance(inst_cfg, dict):
|
||||||
|
p = inst_cfg.get("path") or inst_cfg.get("PATH")
|
||||||
|
if p:
|
||||||
|
return expand_path(p)
|
||||||
|
|
||||||
# Fall back to storage.local.path format
|
# Fall back to storage.local.path format
|
||||||
storage = config.get("storage", {})
|
storage = config.get("storage", {})
|
||||||
if isinstance(storage, dict):
|
if isinstance(storage, dict):
|
||||||
|
|||||||
@@ -193,6 +193,20 @@ class search_file(Cmdlet):
|
|||||||
worker_id = str(uuid.uuid4())
|
worker_id = str(uuid.uuid4())
|
||||||
library_root = get_local_storage_path(config or {}) if get_local_storage_path else None
|
library_root = get_local_storage_path(config or {}) if get_local_storage_path else None
|
||||||
|
|
||||||
|
if not library_root:
|
||||||
|
try:
|
||||||
|
from Store import Store
|
||||||
|
storage_registry = Store(config=config or {})
|
||||||
|
# Try the first folder backend
|
||||||
|
for name in storage_registry.list_backends():
|
||||||
|
backend = storage_registry[name]
|
||||||
|
if type(backend).__name__ == "Folder":
|
||||||
|
library_root = expand_path(getattr(backend, "_location", None))
|
||||||
|
if library_root:
|
||||||
|
break
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
db = None
|
db = None
|
||||||
if library_root:
|
if library_root:
|
||||||
try:
|
try:
|
||||||
@@ -553,7 +567,22 @@ class search_file(Cmdlet):
|
|||||||
from API.folder import API_folder_store
|
from API.folder import API_folder_store
|
||||||
|
|
||||||
worker_id = str(uuid.uuid4())
|
worker_id = str(uuid.uuid4())
|
||||||
|
|
||||||
|
from Store import Store
|
||||||
|
storage_registry = Store(config=config or {})
|
||||||
|
|
||||||
library_root = get_local_storage_path(config or {})
|
library_root = get_local_storage_path(config or {})
|
||||||
|
if not library_root:
|
||||||
|
# Fallback for search-file: if no global "default" path is found,
|
||||||
|
# try to use the specific backend mentioned in -store or the first available folder backend.
|
||||||
|
backend_name = storage_backend or "default"
|
||||||
|
try:
|
||||||
|
backend = storage_registry[backend_name]
|
||||||
|
if backend and type(backend).__name__ == "Folder":
|
||||||
|
library_root = expand_path(getattr(backend, "_location", None))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
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)
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
Reference in New Issue
Block a user