diff --git a/tools/ci/chunk_dl.py b/tools/ci/chunk_dl.py index 9b83c54c..79d6e11d 100644 --- a/tools/ci/chunk_dl.py +++ b/tools/ci/chunk_dl.py @@ -19,7 +19,9 @@ MIRRORS = ["", "https://gh-proxy.net/", "https://gh-proxy.com/"] def pick_mirror(url: str): - """HEAD 探测取 Content-Length;返回(实际可用 URL, 字节数)或 (None, 0)。""" + """HEAD 探测取 Content-Length + 前 4 字节 zip 魔数校验(镜像站会回 200 错误页体, + 只看 Content-Length 会把 195 字节的假体当真——2026-11-03 gh-proxy.net 实证)。 + 返回(实际可用 URL, 字节数)或 (None, 0)。非 zip 目标禁用本件。""" for m in MIRRORS: u = m + url r = subprocess.run(["curl", "-sIL", "-m", "30", u], capture_output=True, text=True) @@ -30,8 +32,14 @@ def pick_mirror(url: str): size = int(line.split(":", 1)[1].strip()) except ValueError: size = 0 - if size > 0: - return u, size + if size <= 65536: + continue + head = subprocess.run( + ["curl", "-sL", "-m", "20", "-r", "0-3", "-o", "-", u], + capture_output=True) + if head.stdout[:2] != b"PK": + continue + return u, size return None, 0 diff --git a/tools/ci/mac_setup.sh b/tools/ci/mac_setup.sh index d479eaf2..802361bf 100644 --- a/tools/ci/mac_setup.sh +++ b/tools/ci/mac_setup.sh @@ -116,12 +116,17 @@ if /usr/local/bin/gdstyle --version >/dev/null 2>&1; then log "gdstyle 已在位,跳过" else TGZ="$(mktemp "${TMPDIR:-/tmp}/gdstyle_XXXXXX.tar.gz")" - _ok=0 - for m in "${MIRRORS[@]}"; do - log "下载 gdstyle v${GDSTYLE_VER} darwin(${m:+经 $m})" - if curl -fL --retry 2 -m 600 -o "$TGZ" "${m}${GDSTYLE_URL}"; then _ok=1; break; fi - done - [ "$_ok" = 1 ] || die "gdstyle 下载失败——手动下载 ${GDSTYLE_URL} 解压放 /usr/local/bin/gdstyle 后重跑" + SRC_TGZ="/Users/${INVOKER}/godot-linux/gdstyle-x86_64-apple-darwin.tar.gz" + if [ -s "$SRC_TGZ" ] && tar -tzf "$SRC_TGZ" >/dev/null 2>&1; then + TGZ="$SRC_TGZ"; log "复用已下载 gdstyle 包: $TGZ" + else + _ok=0 + for m in "${MIRRORS[@]}"; do + log "下载 gdstyle v${GDSTYLE_VER} darwin(${m:+经 $m})" + if curl -fL --retry 2 -m 600 -o "$TGZ" "${m}${GDSTYLE_URL}" && tar -tzf "$TGZ" >/dev/null 2>&1; then _ok=1; break; fi + done + [ "$_ok" = 1 ] || die "gdstyle 下载失败——手动下载 ${GDSTYLE_URL} 解压放 /usr/local/bin/gdstyle 后重跑" + fi TMPD="$(mktemp -d)" tar -xzf "$TGZ" -C "$TMPD" BIN="$(find "$TMPD" -type f -name 'gdstyle*' | head -1)"