f
This commit is contained in:
@@ -143,7 +143,8 @@ class HydrusNetwork:
|
|||||||
try:
|
try:
|
||||||
with HTTPClient(timeout=self.timeout,
|
with HTTPClient(timeout=self.timeout,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
verify_ssl=False) as client:
|
verify_ssl=False,
|
||||||
|
retries=1) as client:
|
||||||
response = None
|
response = None
|
||||||
|
|
||||||
if spec.file_path is not None:
|
if spec.file_path is not None:
|
||||||
@@ -206,6 +207,10 @@ class HydrusNetwork:
|
|||||||
finally:
|
finally:
|
||||||
_render_progress(final=True)
|
_render_progress(final=True)
|
||||||
|
|
||||||
|
upload_attempts = 3
|
||||||
|
last_upload_exc: Exception | None = None
|
||||||
|
for attempt in range(upload_attempts):
|
||||||
|
try:
|
||||||
response = client.request(
|
response = client.request(
|
||||||
spec.method,
|
spec.method,
|
||||||
url,
|
url,
|
||||||
@@ -214,6 +219,18 @@ class HydrusNetwork:
|
|||||||
raise_for_status=False,
|
raise_for_status=False,
|
||||||
log_http_errors=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:
|
else:
|
||||||
content = None
|
content = None
|
||||||
json_data = None
|
json_data = None
|
||||||
|
|||||||
@@ -397,6 +397,24 @@ class HydrusNetwork(Store):
|
|||||||
if isinstance(hashes, list) and hashes:
|
if isinstance(hashes, list) and hashes:
|
||||||
hydrus_hash = hashes[0]
|
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:
|
if not hydrus_hash:
|
||||||
raise Exception(f"Hydrus response missing file hash: {response}")
|
raise Exception(f"Hydrus response missing file hash: {response}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user