f
This commit is contained in:
@@ -34,7 +34,6 @@ coerce_to_path = sh.coerce_to_path
|
||||
build_pipeline_preview = sh.build_pipeline_preview
|
||||
get_field = sh.get_field
|
||||
|
||||
from API.folder import read_sidecar, find_sidecar, write_sidecar, API_folder_store
|
||||
from SYS.utils import sha256_file, unique_path
|
||||
from SYS.metadata import write_metadata
|
||||
|
||||
@@ -2401,31 +2400,6 @@ class Add_File(Cmdlet):
|
||||
List[str],
|
||||
List[str]]:
|
||||
"""Load sidecar metadata."""
|
||||
if store and store.lower() == "local":
|
||||
try:
|
||||
from SYS.config import get_local_storage_path
|
||||
|
||||
db_root = get_local_storage_path(config)
|
||||
if db_root:
|
||||
with API_folder_store(Path(db_root)) as db:
|
||||
file_hash = db.get_file_hash(media_path)
|
||||
if file_hash:
|
||||
tags = db.get_tags(file_hash) or []
|
||||
metadata = db.get_metadata(file_hash) or {}
|
||||
url = metadata.get("url") or []
|
||||
f_hash = metadata.get("hash") or file_hash
|
||||
if tags or url or f_hash:
|
||||
return None, f_hash, tags, url
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
sidecar_path = find_sidecar(media_path)
|
||||
if sidecar_path and sidecar_path.exists():
|
||||
h, t, u = read_sidecar(sidecar_path)
|
||||
return sidecar_path, h, t or [], u or []
|
||||
except Exception:
|
||||
pass
|
||||
return None, None, [], []
|
||||
|
||||
@staticmethod
|
||||
@@ -2465,26 +2439,7 @@ class Add_File(Cmdlet):
|
||||
duration: Any,
|
||||
media_kind: str,
|
||||
):
|
||||
payload = {
|
||||
"hash": f_hash,
|
||||
"url": url,
|
||||
"relationships": relationships or [],
|
||||
"duration": duration,
|
||||
"size": None,
|
||||
"ext": dest_path.suffix.lower(),
|
||||
"media_type": media_kind,
|
||||
"media_kind": media_kind,
|
||||
}
|
||||
try:
|
||||
payload["size"] = dest_path.stat().st_size
|
||||
except OSError:
|
||||
payload["size"] = None
|
||||
|
||||
with API_folder_store(library_root) as db:
|
||||
try:
|
||||
db.save_file_info(dest_path, payload, tags)
|
||||
except Exception as exc:
|
||||
log(f"⚠️ Failed to persist metadata: {exc}", file=sys.stderr)
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def _copy_sidecars(source_path: Path, target_path: Path):
|
||||
|
||||
Reference in New Issue
Block a user