Skip to content

Commit 9628b35

Browse files
committed
fix(mirror): verify with propagation patience — eager 404->delete deleted good uploads
Freshly uploaded GitHub release assets 404 on the download URL for a few seconds; the verify loop treated that as a bad asset and DELETED it, then re-uploaded and deleted again until the job timeout (0.0.86 publish-ecosystem). Verify up to ~18s before concluding failure; only then delete + retry. Same patience on the GitCode side.
1 parent 1e44ae3 commit 9628b35

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

.github/tools/mirror_res.sh

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,19 @@ if [[ -n "${XLINGS_RES_TOKEN:-}" ]] || gh auth status >/dev/null 2>&1; then
6868
fi
6969
for try in 1 2 3 4 5; do
7070
GH_TOKEN="${XLINGS_RES_TOKEN:-}" timeout 300 gh release upload "$VER" "$DL/$a" -R "$GH_DST" --clobber || true
71-
if [[ "$(curl -fsSL -o /dev/null -w '%{http_code}' -L "https://github.com/${GH_DST}/releases/download/${VER}/${a}" 2>/dev/null)" == 200 ]]; then
72-
break
73-
fi
74-
echo "[mirror] gh $a not 200 after try $try; delete + reupload..."
71+
# Freshly uploaded assets take a few seconds to propagate to the
72+
# download CDN. Verify with patience — an eager 404→delete loop
73+
# DELETED successfully uploaded assets over and over (0.0.86
74+
# incident). Only delete + retry after propagation clearly failed.
75+
ok=""
76+
for v in 1 2 3 4 5 6; do
77+
sleep 3
78+
if [[ "$(curl -fsSL -o /dev/null -w '%{http_code}' -L "https://github.com/${GH_DST}/releases/download/${VER}/${a}" 2>/dev/null)" == 200 ]]; then
79+
ok=1; break
80+
fi
81+
done
82+
[[ -n "$ok" ]] && break
83+
echo "[mirror] gh $a still not 200 ~18s after upload (try $try); delete + reupload..."
7584
GH_TOKEN="${XLINGS_RES_TOKEN:-}" gh release delete-asset "$VER" "$a" -R "$GH_DST" -y 2>/dev/null || true
7685
sleep 4
7786
done
@@ -95,9 +104,14 @@ if [[ -n "${GITCODE_TOKEN:-}" ]] && command -v gtc >/dev/null 2>&1; then
95104
fi
96105
for try in 1 2 3 4 5; do
97106
timeout 300 gtc release upload "$GTC_DST" "$DL/$a" --tag "$VER" >/dev/null 2>&1 || true
98-
if [[ "$(curl -fsSL -o /dev/null -w '%{http_code}' -L "https://gitcode.com/${GTC_DST}/releases/download/${VER}/${a}" 2>/dev/null)" == 200 ]]; then
99-
break
100-
fi
107+
ok=""
108+
for v in 1 2 3 4 5 6; do
109+
sleep 3
110+
if [[ "$(curl -fsSL -o /dev/null -w '%{http_code}' -L "https://gitcode.com/${GTC_DST}/releases/download/${VER}/${a}" 2>/dev/null)" == 200 ]]; then
111+
ok=1; break
112+
fi
113+
done
114+
[[ -n "$ok" ]] && break
101115
echo "[mirror] gtc $a not 200 after try $try, retrying..."; sleep 4
102116
done
103117
done

0 commit comments

Comments
 (0)