This commit is contained in:
2026-01-14 18:15:00 -08:00
parent d474916874
commit f40d0b61a2
4 changed files with 122 additions and 59 deletions

View File

@@ -1017,34 +1017,34 @@ class Add_File(Cmdlet):
except Exception:
pass
# PRIORITY 1b: Try hash+store from result dict (fetch from backend)
if isinstance(result, dict):
r_hash = result.get("hash")
r_store = result.get("store")
if r_hash and r_store:
try:
store = store_instance
if not store:
store = Store(config)
# PRIORITY 1b: Try hash+store from result (fetch from backend)
r_hash = get_field(result, "hash") or get_field(result, "file_hash")
r_store = get_field(result, "store")
if r_hash and r_store:
try:
store = store_instance
if not store:
store = Store(config)
if r_store in store.list_backends():
backend = store[r_store]
# Try direct access (Path)
mp = backend.get_file(r_hash)
if isinstance(mp, Path) and mp.exists():
pipe_obj.path = str(mp)
return mp, str(r_hash), None
if r_store in store.list_backends():
backend = store[r_store]
# Try direct access (Path)
mp = backend.get_file(r_hash)
if isinstance(mp, Path) and mp.exists():
pipe_obj.path = str(mp)
return mp, str(r_hash), None
# Try download to temp
if isinstance(mp, str) and mp.strip():
dl_path, tmp_dir = Add_File._maybe_download_backend_file(
backend, str(r_hash), pipe_obj
)
if dl_path and dl_path.exists():
pipe_obj.path = str(dl_path)
return dl_path, str(r_hash), tmp_dir
except Exception:
pass
# Try download to temp
if isinstance(mp, str) and mp.strip():
dl_path, tmp_dir = Add_File._maybe_download_backend_file(
backend, str(r_hash), pipe_obj
)
if dl_path and dl_path.exists():
pipe_obj.path = str(dl_path)
return dl_path, str(r_hash), tmp_dir
except Exception:
pass
# PRIORITY 2: Generic Coercion (Path arg > PipeObject > Result)
candidate: Optional[Path] = None
@@ -1130,7 +1130,6 @@ class Add_File(Cmdlet):
return files_info
@staticmethod
@staticmethod
def _validate_source(media_path: Optional[Path], allow_all_extensions: bool = False) -> bool:
"""Validate that the source file exists and is supported.