dfd
This commit is contained in:
@@ -1554,22 +1554,10 @@ class Add_File(Cmdlet):
|
||||
return 1
|
||||
|
||||
try:
|
||||
hoster_url = provider.upload_to_room(str(media_path), str(room_id))
|
||||
hoster_url = provider.upload_to_room(str(media_path), str(room_id), pipe_obj=pipe_obj)
|
||||
log(f"File uploaded: {hoster_url}", file=sys.stderr)
|
||||
|
||||
# Associate URL with Hydrus if possible
|
||||
f_hash = Add_File._resolve_file_hash(None, media_path, pipe_obj, None)
|
||||
if f_hash:
|
||||
try:
|
||||
store_name = getattr(pipe_obj, "store", None)
|
||||
if store_name:
|
||||
store = Store(config)
|
||||
backend = store[str(store_name)]
|
||||
client = getattr(backend, "_client", None)
|
||||
if client is not None and hasattr(client, "associate_url"):
|
||||
client.associate_url(str(f_hash), hoster_url)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
except Exception as exc:
|
||||
log(f"Upload failed: {exc}", file=sys.stderr)
|
||||
@@ -1676,24 +1664,10 @@ class Add_File(Cmdlet):
|
||||
log(f"File provider '{provider_name}' not available", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
hoster_url = file_provider.upload(str(media_path))
|
||||
hoster_url = file_provider.upload(str(media_path), pipe_obj=pipe_obj)
|
||||
log(f"File uploaded: {hoster_url}", file=sys.stderr)
|
||||
|
||||
# Associate URL with Hydrus if possible
|
||||
f_hash = Add_File._resolve_file_hash(None, media_path, pipe_obj, None)
|
||||
if f_hash:
|
||||
try:
|
||||
# Only associate when we can target an explicit Hydrus store backend.
|
||||
# Do not fall back to a global/default Hydrus client.
|
||||
store_name = getattr(pipe_obj, "store", None)
|
||||
if store_name:
|
||||
store = Store(config)
|
||||
backend = store[str(store_name)]
|
||||
client = getattr(backend, "_client", None)
|
||||
if client is not None and hasattr(client, "associate_url"):
|
||||
client.associate_url(str(f_hash), hoster_url)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
except Exception as exc:
|
||||
log(f"Upload failed: {exc}", file=sys.stderr)
|
||||
|
||||
Reference in New Issue
Block a user