mirror of
https://github.com/RROrg/rr.git
synced 2025-12-08 21:19:43 +08:00
优化数据获取逻辑,添加下载失败重试机制
This commit is contained in:
parent
a1734d9a76
commit
6f7fd358d6
33
.github/workflows/data.yml
vendored
33
.github/workflows/data.yml
vendored
@ -33,27 +33,30 @@ jobs:
|
||||
git config --global user.name "github-actions[bot]"
|
||||
sudo timedatectl set-timezone "Asia/Shanghai"
|
||||
|
||||
- name: Delay
|
||||
run: |
|
||||
echo "Delaying for 1 minutes..."
|
||||
sleep 60
|
||||
|
||||
- name: Get Data
|
||||
run: |
|
||||
REPO="${{ github.server_url }}/${{ github.repository }}"
|
||||
PRERELEASE="true"
|
||||
|
||||
TAG=""
|
||||
if [ "${PRERELEASE}" = "true" ]; then
|
||||
TAG="$(curl -skL --connect-timeout 10 "${REPO}/tags" | grep "/refs/tags/.*\.zip" | sed -E 's/.*\/refs\/tags\/(.*)\.zip.*$/\1/' | sort -rV | head -1)"
|
||||
else
|
||||
TAG="$(curl -skL --connect-timeout 10 -w "%{url_effective}" -o /dev/null "${REPO}/releases/latest" | awk -F'/' '{print $NF}')"
|
||||
fi
|
||||
[ "${TAG:0:1}" = "v" ] && TAG="${TAG:1}"
|
||||
rm -f rr-${TAG}.img.zip
|
||||
STATUS=$(curl -kL --connect-timeout 10 -w "%{http_code}" "${REPO}/releases/download/${TAG}/rr-${TAG}.img.zip" -o "rr-${TAG}.img.zip")
|
||||
if [ $? -ne 0 ] || [ ${STATUS:-0} -ne 200 ]; then
|
||||
echo "Download failed"
|
||||
for i in {1..3}; do
|
||||
if [ "${PRERELEASE}" = "true" ]; then
|
||||
TAG="$(curl -skL --connect-timeout 10 "${REPO}/tags" | grep "/refs/tags/.*\.zip" | sed -E 's/.*\/refs\/tags\/(.*)\.zip.*$/\1/' | sort -rV | head -1)"
|
||||
else
|
||||
TAG="$(curl -skL --connect-timeout 10 -w "%{url_effective}" -o /dev/null "${REPO}/releases/latest" | awk -F'/' '{print $NF}')"
|
||||
fi
|
||||
[ "${TAG:0:1}" = "v" ] && TAG="${TAG:1}"
|
||||
rm -f rr-${TAG}.img.zip
|
||||
STATUS=$(curl -kL --connect-timeout 10 -w "%{http_code}" "${REPO}/releases/download/${TAG}/rr-${TAG}.img.zip" -o "rr-${TAG}.img.zip")
|
||||
if [ $? -eq 0 ] && [ ${STATUS:-0} -eq 200 ]; then
|
||||
break
|
||||
else
|
||||
echo "Download failed, retry $i/3"
|
||||
sleep 60
|
||||
fi
|
||||
done
|
||||
if [ ! -f "rr-${TAG}.img.zip" ] || [ ${STATUS:-0} -ne 200 ]; then
|
||||
echo "Download failed after 3 attempts"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user