diff --git a/bootstrap.sh b/bootstrap.sh index b45b401..cd1a653 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -6,9 +6,11 @@ set -euo pipefail REPO="anten-ka/gotelegram_pro" BRANCH="${GOTELEGRAM_BRANCH:-test}" -PAT="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" +PAT="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" INSTALL_DIR="/opt/gotelegram" -API="https://api.github.com/repos/${REPO}/contents" +# Use raw.githubusercontent.com (CDN) — faster and avoids Contents API caching +# issues that occasionally return 404 for recently added files on non-default branches. +RAW="https://raw.githubusercontent.com/${REPO}/${BRANCH}" RED='\033[0;31m' GREEN='\033[0;32m' @@ -47,17 +49,20 @@ download_file() { dir=$(dirname "$local_path") mkdir -p "$dir" - local http_code - http_code=$(curl -sL -w "%{http_code}" -o "$local_path" \ - -H "Authorization: token ${PAT}" \ - -H "Accept: application/vnd.github.raw" \ - "${API}/${remote_path}?ref=${BRANCH}") + # Retry up to 3 times with short backoff to tolerate transient CDN hiccups + local attempt http_code + for attempt in 1 2 3; do + http_code=$(curl -sL -w "%{http_code}" -o "$local_path" \ + -H "Authorization: token ${PAT}" \ + "${RAW}/${remote_path}") + if [ "$http_code" = "200" ]; then + return 0 + fi + sleep 1 + done - if [ "$http_code" != "200" ]; then - echo -e " ${RED}✗${NC} Ошибка загрузки ${remote_path} (HTTP ${http_code})" - return 1 - fi - return 0 + echo -e " ${RED}✗${NC} Ошибка загрузки ${remote_path} (HTTP ${http_code})" + return 1 } # File list