From c2d093bc9013ad48b6720626c8855bac7411f7c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9A=E7=AB=A0=E6=B5=A9?= Date: Sun, 13 Sep 2026 23:49:01 +0800 Subject: [PATCH] fix(fetch): AList download route authenticates with x-api-token This AList deployment (sales.dobotoa.cn family) only recognizes x-api-token on the /p/ download route; an Authorization header gets 302'd to login.dingtalk.com. Probe x-api-token first, fall back to Authorization, then fail-closed. --- scripts/artifact_fetch.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/artifact_fetch.py b/scripts/artifact_fetch.py index ad15837..cb48b48 100644 --- a/scripts/artifact_fetch.py +++ b/scripts/artifact_fetch.py @@ -201,9 +201,17 @@ def alist_download(manifest, max_bytes): if manifest.get("size_bytes") in (None, 0) and data.get("size"): manifest["size_bytes"] = int(data["size"]) download_url = urllib.parse.urljoin(base_url + "/", raw_url.lstrip("/")) + # This AList deployment gates the download route with x-api-token (the + # Authorization header is NOT recognized there): wrong auth yields a 302 + # to the DingTalk login page instead of bytes. try: - return http_get(download_url, {"Authorization": token}, 180, max_bytes) + return http_get(download_url, {"x-api-token": token}, 180, max_bytes) except FetchError as error: + if error.code == "source_auth_required": + try: + return http_get(download_url, {"Authorization": token}, 180, max_bytes) + except FetchError: + raise error if error.code == "redirect": # Same-origin /d/ route 302s to a signed external URL: follow once # WITHOUT the source token (never forward credentials cross-origin).