build: make GitHub archive fallback resumable
Download archive into .part, validate with gzip -t, retry, then extract. Helps on flaky TLS connections.
This commit is contained in:
parent
f84cd6a168
commit
2a0e5c9f07
|
|
@ -365,12 +365,32 @@ fetch_from_github_archive()
|
||||||
local tar_url="${base}/archive/refs/heads/${ref_name}.tar.gz"
|
local tar_url="${base}/archive/refs/heads/${ref_name}.tar.gz"
|
||||||
local archive_dir="${EXTER}/cache/sources/.github-archives"
|
local archive_dir="${EXTER}/cache/sources/.github-archives"
|
||||||
local tar_path="${archive_dir}/$(basename "${base}")-${ref_name}.tar.gz"
|
local tar_path="${archive_dir}/$(basename "${base}")-${ref_name}.tar.gz"
|
||||||
|
local tar_part="${tar_path}.part"
|
||||||
|
|
||||||
mkdir -p "${archive_dir}" || return 1
|
mkdir -p "${archive_dir}" || return 1
|
||||||
|
|
||||||
display_alert "Downloading GitHub archive" "${tar_url}" "wrn"
|
display_alert "Downloading GitHub archive" "${tar_url}" "wrn"
|
||||||
# -c enables resume; keep a cached tarball in EXTER/cache/sources
|
local attempt
|
||||||
wget -q -c -t 10 --timeout=30 --waitretry=5 -O "${tar_path}" "${tar_url}" || return 1
|
for attempt in 1 2 3; do
|
||||||
|
# Resume into a .part file, verify integrity, then promote.
|
||||||
|
if command -v curl >/dev/null 2>&1; then
|
||||||
|
curl -L --fail --retry 10 --retry-delay 5 --connect-timeout 30 \
|
||||||
|
--continue-at - -o "${tar_part}" "${tar_url}" || true
|
||||||
|
else
|
||||||
|
wget -c -t 10 --timeout=30 --waitretry=5 -O "${tar_part}" "${tar_url}" || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if gzip -t "${tar_part}" >/dev/null 2>&1; then
|
||||||
|
mv -f "${tar_part}" "${tar_path}" || return 1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
display_alert "Archive download incomplete; retrying" "attempt ${attempt}/3" "wrn"
|
||||||
|
rm -f "${tar_part}" 2>/dev/null || true
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
|
||||||
|
[[ -f "${tar_path}" ]] || return 1
|
||||||
|
|
||||||
display_alert "Extracting archive" "${workdir}" "wrn"
|
display_alert "Extracting archive" "${workdir}" "wrn"
|
||||||
mkdir -p "${workdir}" || return 1
|
mkdir -p "${workdir}" || return 1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue