mirror of
https://github.com/dockur/windows.git
synced 2026-08-03 12:37:20 +01:00
build: Update workflow (#2012)
This commit is contained in:
+85
-63
@@ -48,81 +48,101 @@ jobs:
|
||||
check() {
|
||||
local url="$1"
|
||||
local agent="Mozilla/5.0 (X11; Linux x86_64; rv:154.0) Gecko/20100101 Firefox/154.0"
|
||||
local tmp output pid blocks bytes rc
|
||||
local start=$SECONDS
|
||||
local tmp output pid blocks bytes rc status delay
|
||||
local attempt=1
|
||||
local attempts=3
|
||||
local start
|
||||
|
||||
tmp=$(mktemp -d)
|
||||
output="$tmp/aria2.log"
|
||||
|
||||
aria2c \
|
||||
--no-conf=true \
|
||||
--connect-timeout=30 \
|
||||
--timeout=30 \
|
||||
--max-tries=2 \
|
||||
--retry-wait=2 \
|
||||
--async-dns=false \
|
||||
--follow-metalink=false \
|
||||
--follow-torrent=false \
|
||||
--user-agent="$agent" \
|
||||
--split=4 \
|
||||
--max-connection-per-server=4 \
|
||||
--file-allocation=none \
|
||||
--allow-overwrite=true \
|
||||
--auto-file-renaming=false \
|
||||
--continue=false \
|
||||
--dir="$tmp" \
|
||||
--out=probe \
|
||||
--console-log-level=error \
|
||||
--summary-interval=0 \
|
||||
--download-result=hide \
|
||||
--show-console-readout=false \
|
||||
--enable-color=false \
|
||||
-- "$url" > "$output" 2>&1 &
|
||||
pid=$!
|
||||
while (( attempt <= attempts )); do
|
||||
output="$tmp/aria2.log"
|
||||
rm -f -- "$tmp/probe" "$tmp/probe.aria2" "$output"
|
||||
start=$SECONDS
|
||||
|
||||
aria2c \
|
||||
--no-conf=true \
|
||||
--connect-timeout=30 \
|
||||
--timeout=30 \
|
||||
--max-tries=2 \
|
||||
--retry-wait=2 \
|
||||
--async-dns=false \
|
||||
--follow-metalink=false \
|
||||
--follow-torrent=false \
|
||||
--user-agent="$agent" \
|
||||
--split=4 \
|
||||
--max-connection-per-server=4 \
|
||||
--file-allocation=none \
|
||||
--allow-overwrite=true \
|
||||
--auto-file-renaming=false \
|
||||
--continue=false \
|
||||
--dir="$tmp" \
|
||||
--out=probe \
|
||||
--console-log-level=error \
|
||||
--summary-interval=0 \
|
||||
--download-result=hide \
|
||||
--show-console-readout=false \
|
||||
--enable-color=false \
|
||||
-- "$url" > "$output" 2>&1 &
|
||||
pid=$!
|
||||
|
||||
while kill -0 "$pid" 2>/dev/null; do
|
||||
if [[ -f "$tmp/probe" ]]; then
|
||||
blocks=$(stat -c '%b' "$tmp/probe" 2>/dev/null || echo 0)
|
||||
bytes=$((blocks * 512))
|
||||
|
||||
if (( bytes >= 1048576 )); then
|
||||
kill "$pid" 2>/dev/null || true
|
||||
wait "$pid" 2>/dev/null || true
|
||||
rm -rf -- "$tmp"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if (( SECONDS - start >= 60 )); then
|
||||
kill "$pid" 2>/dev/null || true
|
||||
break
|
||||
fi
|
||||
|
||||
sleep 0.2
|
||||
done
|
||||
|
||||
if wait "$pid"; then
|
||||
rc=0
|
||||
else
|
||||
rc=$?
|
||||
fi
|
||||
|
||||
blocks=0
|
||||
|
||||
while kill -0 "$pid" 2>/dev/null; do
|
||||
if [[ -f "$tmp/probe" ]]; then
|
||||
blocks=$(stat -c '%b' "$tmp/probe" 2>/dev/null || echo 0)
|
||||
bytes=$((blocks * 512))
|
||||
|
||||
if (( bytes >= 1048576 )); then
|
||||
kill "$pid" 2>/dev/null || true
|
||||
wait "$pid" 2>/dev/null || true
|
||||
rm -rf -- "$tmp"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if (( SECONDS - start >= 60 )); then
|
||||
kill "$pid" 2>/dev/null || true
|
||||
break
|
||||
bytes=$((blocks * 512))
|
||||
|
||||
if (( bytes >= 1048576 || (rc == 0 && bytes > 0) )); then
|
||||
rm -rf -- "$tmp"
|
||||
return 0
|
||||
fi
|
||||
|
||||
sleep 0.2
|
||||
status=$(sed -n 's/.*status=\([0-9][0-9][0-9]\).*/\1/p' "$output" | tail -n 1)
|
||||
|
||||
if (( attempt < attempts )) && [[ "$status" == "429" || "$status" == 5?? ]]; then
|
||||
delay=$((attempt * 15))
|
||||
echo " HTTP ${status}, retrying in ${delay} seconds..." >&2
|
||||
sleep "$delay"
|
||||
attempt=$((attempt + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
sed 's/^/ /' "$output" >&2
|
||||
echo " Downloaded bytes: $bytes" >&2
|
||||
echo " aria2c exit status: $rc" >&2
|
||||
rm -rf -- "$tmp"
|
||||
return 1
|
||||
done
|
||||
|
||||
if wait "$pid"; then
|
||||
rc=0
|
||||
else
|
||||
rc=$?
|
||||
fi
|
||||
|
||||
blocks=0
|
||||
|
||||
if [[ -f "$tmp/probe" ]]; then
|
||||
blocks=$(stat -c '%b' "$tmp/probe" 2>/dev/null || echo 0)
|
||||
fi
|
||||
|
||||
bytes=$((blocks * 512))
|
||||
|
||||
if (( bytes >= 1048576 || (rc == 0 && bytes > 0) )); then
|
||||
rm -rf -- "$tmp"
|
||||
return 0
|
||||
fi
|
||||
|
||||
sed 's/^/ /' "$output" >&2
|
||||
echo " Downloaded bytes: $bytes" >&2
|
||||
echo " aria2c exit status: $rc" >&2
|
||||
rm -rf -- "$tmp"
|
||||
return 1
|
||||
}
|
||||
@@ -180,6 +200,8 @@ jobs:
|
||||
failed_links+="$url"$'\n'
|
||||
failed_links_html+="<li><a href=\"$url\">$url</a></li>"$'\n'
|
||||
fi
|
||||
|
||||
sleep 2
|
||||
done < "src/define.sh"
|
||||
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user