updated
This commit is contained in:
+31
-3
@@ -98,7 +98,7 @@ DEBUG_PIPE_NOTE_PREVIEW_LENGTH = 256
|
||||
# Used by multiple methods in this file to guard against URL strings being
|
||||
# treated as local file paths.
|
||||
_REMOTE_URL_PREFIXES: tuple[str, ...] = (
|
||||
"http://", "https://", "magnet:", "torrent:", "tidal:", "hydrus:",
|
||||
"http://", "https://", "ftp://", "ftps://", "magnet:", "torrent:", "tidal:", "hydrus:",
|
||||
)
|
||||
|
||||
|
||||
@@ -1241,6 +1241,11 @@ class Add_File(Cmdlet):
|
||||
return None, None
|
||||
if not url_text.lower().startswith(_REMOTE_URL_PREFIXES):
|
||||
return None, None
|
||||
# This helper performs generic HTTP downloads only.
|
||||
# Non-HTTP schemes (e.g. hydrus://, tidal:) should be handled by
|
||||
# plugin-specific resolvers via _maybe_download_plugin_result.
|
||||
if not url_text.lower().startswith(("http://", "https://")):
|
||||
return None, None
|
||||
|
||||
tmp_dir: Optional[Path] = None
|
||||
try:
|
||||
@@ -1480,8 +1485,31 @@ class Add_File(Cmdlet):
|
||||
if candidate:
|
||||
s = str(candidate).lower()
|
||||
if s.startswith(_REMOTE_URL_PREFIXES):
|
||||
log("add-file ingests local files only. Use download-file first.", file=sys.stderr)
|
||||
return None, None, None
|
||||
# For remote sources, prefer plugin-specific resolvers first
|
||||
# (e.g. hydrus://), then generic HTTP fallback.
|
||||
downloaded_path, hash_hint, tmp_dir = Add_File._maybe_download_plugin_result(
|
||||
result,
|
||||
pipe_obj,
|
||||
config,
|
||||
deps=deps,
|
||||
)
|
||||
if downloaded_path:
|
||||
pipe_obj.path = str(downloaded_path)
|
||||
return downloaded_path, hash_hint, tmp_dir
|
||||
|
||||
dl_path, tmp_dir = Add_File._download_remote_backend_url(
|
||||
str(candidate),
|
||||
pipe_obj,
|
||||
file_hash=get_field(result, "hash") or get_field(result, "file_hash"),
|
||||
output_dir=export_destination,
|
||||
)
|
||||
if dl_path:
|
||||
pipe_obj.path = str(dl_path)
|
||||
hash_hint = get_field(result, "hash") or get_field(result, "file_hash")
|
||||
return dl_path, hash_hint, tmp_dir
|
||||
|
||||
log("add-file could not auto-fetch remote source. Use download-file first.", file=sys.stderr)
|
||||
return None, None, None
|
||||
|
||||
pipe_obj.path = str(candidate)
|
||||
# Retain hash from input if available to avoid re-hashing
|
||||
|
||||
Reference in New Issue
Block a user