From d3c7586a15228eac88fc9f0d59a4796dfec5c674 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Sun, 22 Oct 2023 16:38:21 +0800 Subject: [PATCH] =?UTF-8?q?core:=20=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E9=93=BE=E6=8E=A5=E6=97=B6=EF=BC=8C=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E4=B8=8D=E6=94=AF=E6=8C=81=20range?= =?UTF-8?q?=EF=BC=8Ccurl=20=E4=BC=9A=E4=B8=8B=E8=BD=BD=E6=95=B4=E4=B8=AA?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reinstall.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/reinstall.sh b/reinstall.sh index 878b0a5..7d02055 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -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 + + # 有的服务器不支持 range,curl会下载整个文件 + # 用 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有很多种写法