core: 修复了测试链接时,如果服务器不支持 range,curl 会下载整个文件

This commit is contained in:
bin456789 2023-10-22 16:38:21 +08:00
parent b42bb67c57
commit d3c7586a15
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B

View File

@ -162,9 +162,17 @@ test_url_real() {
}
tmp_file=/tmp/reinstall-img-test
if ! curl -r 0-1048575 -Lo "$tmp_file" "$url"; then
failed "$url not accessible"
fi
# 有的服务器不支持 rangecurl会下载整个文件
# 用 dd 限制下载 1M
# 并过滤 curl 23 错误dd限制了空间
# 也可用 ulimit -f 但好像 cygwin 不支持
curl -Lr 0-1048575 "$url" \
1> >(dd bs=1M count=1 of=$tmp_file iflag=fullblock 2>/dev/null) \
2> >(grep -v 'curl: (23)' >&2) ||
if [ ! $? -eq 23 ]; then
failed "$url not accessible"
fi
if [ -n "$expect_type" ]; then
# gzip的mime有很多种写法