This commit is contained in:
2026-02-07 14:32:33 -08:00
parent af54acda3c
commit c8230cbb42
2 changed files with 44 additions and 9 deletions

View File

@@ -143,7 +143,8 @@ class HydrusNetwork:
try:
with HTTPClient(timeout=self.timeout,
headers=headers,
verify_ssl=False) as client:
verify_ssl=False,
retries=1) as client:
response = None
if spec.file_path is not None:
@@ -206,6 +207,10 @@ class HydrusNetwork:
finally:
_render_progress(final=True)
upload_attempts = 3
last_upload_exc: Exception | None = None
for attempt in range(upload_attempts):
try:
response = client.request(
spec.method,
url,
@@ -214,6 +219,18 @@ class HydrusNetwork:
raise_for_status=False,
log_http_errors=False,
)
last_upload_exc = None
break
except (httpx.TimeoutException, httpx.RequestError) as exc:
last_upload_exc = exc
logger.warning(
f"{self._log_prefix()} Upload timeout/error on attempt {attempt + 1}/{upload_attempts}: {exc}"
)
if attempt < upload_attempts - 1:
continue
raise
if response is None and last_upload_exc is not None:
raise last_upload_exc
else:
content = None
json_data = None

View File

@@ -397,6 +397,24 @@ class HydrusNetwork(Store):
if isinstance(hashes, list) and hashes:
hydrus_hash = hashes[0]
if isinstance(hydrus_hash, (bytes, bytearray)):
try:
hydrus_hash = bytes(hydrus_hash).hex()
except Exception:
hydrus_hash = None
if hydrus_hash:
try:
hydrus_hash = str(hydrus_hash).strip().lower()
except Exception:
hydrus_hash = None
if not hydrus_hash or len(str(hydrus_hash)) != 64:
debug(
f"{self._log_prefix()} Hydrus response hash missing/invalid; using precomputed hash"
)
hydrus_hash = file_hash
if not hydrus_hash:
raise Exception(f"Hydrus response missing file hash: {response}")