Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
640061db21 | ||
|
|
59ff86d30f |
+49
-5
@@ -42,12 +42,56 @@ fi
|
|||||||
download_if_missing() {
|
download_if_missing() {
|
||||||
local url="$1"
|
local url="$1"
|
||||||
local dest="$2"
|
local dest="$2"
|
||||||
if [ ! -s "$dest" ]; then
|
local label
|
||||||
echo "==> Downloading $(basename "$dest")..."
|
label="$(basename "$(dirname "$dest")")/$(basename "$dest")"
|
||||||
mkdir -p "$(dirname "$dest")"
|
|
||||||
curl -fsSL "$url" -o "$dest"
|
if [ -s "$dest" ]; then
|
||||||
chmod +x "$dest"
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
mkdir -p "$(dirname "$dest")"
|
||||||
|
|
||||||
|
local max_attempts=5
|
||||||
|
local attempt=1
|
||||||
|
local tmp="${dest}.tmp.$$"
|
||||||
|
|
||||||
|
while [ "$attempt" -le "$max_attempts" ]; do
|
||||||
|
local sep="?"
|
||||||
|
case "$url" in
|
||||||
|
*\?*) sep="&" ;;
|
||||||
|
esac
|
||||||
|
# GitHub release download URLs 302-redirect to short-lived (5m) JWT asset URLs.
|
||||||
|
# A unique cache-busting query parameter ensures intermediate HTTP caches/proxies
|
||||||
|
# cannot serve a stale 302 redirect with an expired JWT (HTTP 618 / curl exit 22).
|
||||||
|
local req_url="${url}${sep}cb=$(date +%s)-$$-${RANDOM:-0}-${attempt}"
|
||||||
|
|
||||||
|
if [ "$attempt" -eq 1 ]; then
|
||||||
|
echo "==> Downloading ${label}..."
|
||||||
|
else
|
||||||
|
echo "==> Retrying ${label} (attempt ${attempt}/${max_attempts})..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f "$tmp"
|
||||||
|
if curl -fsSL \
|
||||||
|
--connect-timeout 15 \
|
||||||
|
--max-time 120 \
|
||||||
|
-H "Cache-Control: no-cache" \
|
||||||
|
-H "Pragma: no-cache" \
|
||||||
|
"$req_url" -o "$tmp" && [ -s "$tmp" ]; then
|
||||||
|
chmod +x "$tmp"
|
||||||
|
mv "$tmp" "$dest"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f "$tmp"
|
||||||
|
if [ "$attempt" -lt "$max_attempts" ]; then
|
||||||
|
sleep $((attempt * 2))
|
||||||
|
fi
|
||||||
|
attempt=$((attempt + 1))
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "ERROR: Failed to download ${label} from ${url} after ${max_attempts} attempts." >&2
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "==> Fetching NextUI UI binaries (minui-list $MINUI_LIST_VER & minui-presenter $MINUI_PRESENTER_VER)..."
|
echo "==> Fetching NextUI UI binaries (minui-list $MINUI_LIST_VER & minui-presenter $MINUI_PRESENTER_VER)..."
|
||||||
|
|||||||
Reference in new issue
Block a user