f
This commit is contained in:
@@ -1272,8 +1272,19 @@ class HydrusNetwork(Store):
|
|||||||
IMPORTANT: this method must be side-effect free (do not auto-open a browser).
|
IMPORTANT: this method must be side-effect free (do not auto-open a browser).
|
||||||
Only explicit user actions (e.g. the get-file cmdlet) should open files.
|
Only explicit user actions (e.g. the get-file cmdlet) should open files.
|
||||||
"""
|
"""
|
||||||
|
file_hash = str(file_hash or "").strip().lower()
|
||||||
|
debug(f"{self._log_prefix()} get_file(hash={file_hash[:12]}..., url={kwargs.get('url')})")
|
||||||
|
|
||||||
debug(f"{self._log_prefix()} get_file: start hash={file_hash[:12]}...")
|
# If 'url=True' is passed, we preference the browser URL even if a local path is available.
|
||||||
|
# This is typically used by the 'get-file' cmdlet for interactive viewing.
|
||||||
|
if kwargs.get("url"):
|
||||||
|
base_url = str(self.URL).rstrip("/")
|
||||||
|
access_key = str(self.API)
|
||||||
|
browser_url = (
|
||||||
|
f"{base_url}/get_files/file?hash={file_hash}&Hydrus-Client-API-Access-Key={access_key}"
|
||||||
|
)
|
||||||
|
debug(f"{self._log_prefix()} get_file: returning browser URL per request: {browser_url}")
|
||||||
|
return browser_url
|
||||||
|
|
||||||
# Try to get the local disk path if possible (works if Hydrus is on same machine)
|
# Try to get the local disk path if possible (works if Hydrus is on same machine)
|
||||||
server_path = None
|
server_path = None
|
||||||
|
|||||||
@@ -139,8 +139,12 @@ class Get_File(sh.Cmdlet):
|
|||||||
|
|
||||||
debug(f"[get-file] Calling backend.get_file({file_hash})")
|
debug(f"[get-file] Calling backend.get_file({file_hash})")
|
||||||
|
|
||||||
# Get file from backend (may return Path or URL string depending on backend)
|
# Get file from backend (may return Path or URL string depending on backend).
|
||||||
source_path = backend.get_file(file_hash)
|
# We pass url=True if no explicit path was provided, which hints the backend
|
||||||
|
# (specifically Hydrus) to return a browser-friendly URL instead of a local path.
|
||||||
|
want_url = (output_path is None)
|
||||||
|
debug(f"[get-file] Requesting file from backend (url_hint={want_url})...")
|
||||||
|
source_path = backend.get_file(file_hash, url=want_url)
|
||||||
|
|
||||||
debug(f"[get-file] backend.get_file returned: {source_path}")
|
debug(f"[get-file] backend.get_file returned: {source_path}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user