Retry manifest fetch with access_token on 404 when token present
This commit is contained in:
@@ -119,6 +119,17 @@ def fetch_manifest(url: str | None = None):
|
|||||||
data = resp.read()
|
data = resp.read()
|
||||||
return json.loads(data.decode())
|
return json.loads(data.decode())
|
||||||
except urllib.error.HTTPError as e:
|
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:
|
if e.code == 404:
|
||||||
alt = _gitea_latest_manifest(target)
|
alt = _gitea_latest_manifest(target)
|
||||||
if alt:
|
if alt:
|
||||||
|
|||||||
Reference in New Issue
Block a user