jj
This commit is contained in:
@@ -13,6 +13,11 @@ import sys
|
||||
from SYS.logger import log, debug
|
||||
from ProviderCore.registry import get_search_provider, list_search_providers
|
||||
from SYS.config import get_local_storage_path
|
||||
from SYS.rich_display import (
|
||||
show_provider_config_panel,
|
||||
show_store_config_panel,
|
||||
show_available_providers_panel,
|
||||
)
|
||||
|
||||
from . import _shared as sh
|
||||
|
||||
@@ -165,29 +170,54 @@ class search_file(Cmdlet):
|
||||
"""Execute external provider search."""
|
||||
|
||||
if not provider_name or not query:
|
||||
from SYS import pipeline as ctx_mod
|
||||
progress = None
|
||||
if hasattr(ctx_mod, "get_pipeline_state"):
|
||||
progress = ctx_mod.get_pipeline_state().live_progress
|
||||
if progress:
|
||||
try:
|
||||
progress.stop()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
log("Error: search-file -provider requires both provider and query", file=sys.stderr)
|
||||
log(f"Usage: {self.usage}", file=sys.stderr)
|
||||
log("Available providers:", file=sys.stderr)
|
||||
providers = list_search_providers(config)
|
||||
for name, available in sorted(providers.items()):
|
||||
status = "\u2713" if available else "\u2717"
|
||||
log(f" {status} {name}", file=sys.stderr)
|
||||
|
||||
providers_map = list_search_providers(config)
|
||||
available = [n for n, a in providers_map.items() if a]
|
||||
unconfigured = [n for n, a in providers_map.items() if not a]
|
||||
|
||||
if unconfigured:
|
||||
show_provider_config_panel(unconfigured)
|
||||
|
||||
if available:
|
||||
show_available_providers_panel(available)
|
||||
|
||||
return 1
|
||||
|
||||
# Align with provider default when user did not set -limit.
|
||||
if not limit_set:
|
||||
limit = 50
|
||||
|
||||
debug(f"[search-file] provider={provider_name}, query={query}, limit={limit}, open_id={open_id}")
|
||||
|
||||
from SYS import pipeline as ctx_mod
|
||||
progress = None
|
||||
if hasattr(ctx_mod, "get_pipeline_state"):
|
||||
progress = ctx_mod.get_pipeline_state().live_progress
|
||||
|
||||
provider = get_search_provider(provider_name, config)
|
||||
if not provider:
|
||||
log(f"Error: Provider '{provider_name}' is not available", file=sys.stderr)
|
||||
log("Available providers:", file=sys.stderr)
|
||||
providers = list_search_providers(config)
|
||||
for name, available in sorted(providers.items()):
|
||||
if available:
|
||||
log(f" - {name}", file=sys.stderr)
|
||||
if progress:
|
||||
try:
|
||||
progress.stop()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
show_provider_config_panel([provider_name])
|
||||
|
||||
providers_map = list_search_providers(config)
|
||||
available = [n for n, a in providers_map.items() if a]
|
||||
if available:
|
||||
show_available_providers_panel(available)
|
||||
return 1
|
||||
|
||||
worker_id = str(uuid.uuid4())
|
||||
@@ -595,7 +625,16 @@ class search_file(Cmdlet):
|
||||
continue
|
||||
|
||||
if not library_root:
|
||||
log("No library root configured. Use the .config command to set up storage.", file=sys.stderr)
|
||||
from SYS import pipeline as ctx_mod
|
||||
progress = None
|
||||
if hasattr(ctx_mod, "get_pipeline_state"):
|
||||
progress = ctx_mod.get_pipeline_state().live_progress
|
||||
if progress:
|
||||
try:
|
||||
progress.stop()
|
||||
except Exception:
|
||||
pass
|
||||
show_store_config_panel(["Folder Store"])
|
||||
return 1
|
||||
|
||||
# Use context manager to ensure database is always closed
|
||||
|
||||
Reference in New Issue
Block a user