Retry manifest fetch with access_token on 404 when token present

This commit is contained in:
Aaron
2025-12-14 17:37:35 -05:00
parent 7a9ffb710a
commit 009ac8cdd0

View File

@@ -119,6 +119,17 @@ def fetch_manifest(url: str | None = None):
data = resp.read()
return json.loads(data.decode())
except urllib.error.HTTPError as e:
# If raw URL is protected, retry with access_token query param
if e.code == 404 and token and "access_token=" not in target:
try:
sep = "&" if "?" in target else "?"
retry_url = f"{target}{sep}access_token={token}"
req = urllib.request.Request(retry_url)
resp = urllib.request.urlopen(req, timeout=10)
data = resp.read()
return json.loads(data.decode())
except Exception:
pass
if e.code == 404:
alt = _gitea_latest_manifest(target)
if alt: