This commit is contained in:
2026-01-01 20:37:27 -08:00
parent f3c79609d8
commit deb05c0d44
35 changed files with 5030 additions and 4879 deletions

View File

@@ -1389,19 +1389,51 @@ class HydrusNetwork(Store):
if not tags_to_add and not tags_to_remove:
return True
service_key: Optional[str] = None
try:
from API import HydrusNetwork as hydrus_wrapper
service_key = hydrus_wrapper.get_tag_service_key(
client, service_name
)
except Exception:
service_key = None
mutate_success = False
if service_key:
try:
client.mutate_tags_by_key(
file_hash,
service_key,
add_tags=tags_to_add,
remove_tags=tags_to_remove,
)
mutate_success = True
except Exception as exc:
debug(
f"{self._log_prefix()} add_tag: mutate_tags_by_key failed: {exc}"
)
did_any = False
if tags_to_remove:
try:
client.delete_tag(file_hash, tags_to_remove, service_name)
did_any = True
except Exception as exc:
debug(f"{self._log_prefix()} add_tag: delete_tag failed: {exc}")
if tags_to_add:
try:
client.add_tag(file_hash, tags_to_add, service_name)
did_any = True
except Exception as exc:
debug(f"{self._log_prefix()} add_tag: add_tag failed: {exc}")
if not mutate_success:
if tags_to_remove:
try:
client.delete_tag(file_hash, tags_to_remove, service_name)
did_any = True
except Exception as exc:
debug(
f"{self._log_prefix()} add_tag: delete_tag failed: {exc}"
)
if tags_to_add:
try:
client.add_tag(file_hash, tags_to_add, service_name)
did_any = True
except Exception as exc:
debug(
f"{self._log_prefix()} add_tag: add_tag failed: {exc}"
)
else:
did_any = bool(tags_to_add or tags_to_remove)
return did_any
except Exception as exc: