From 90babd1df34e3fec6193bd636090826cb374e14a Mon Sep 17 00:00:00 2001 From: cclohmar Date: Thu, 23 Apr 2026 21:02:21 +0000 Subject: [PATCH] =?UTF-8?q?install.sh:=20fix=20download()=20to=20check=20H?= =?UTF-8?q?TTP=20status=20instead=20of=20content=20=E2=80=94=20template=20?= =?UTF-8?q?files=20contain=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace fragile head -c 100 | grep content check with curl -w '%{http_code}' for accurate HTTP status detection - The old check incorrectly rejected legitimate HTML template files (base.html starts with ) - wget fallback uses its exit code instead (no content scanning) --- install.sh | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/install.sh b/install.sh index 0dc02b9..c9a6e89 100755 --- a/install.sh +++ b/install.sh @@ -101,23 +101,30 @@ download() { local tmpfile tmpfile="$(mktemp)" + local http_code if [[ "${DOWNLOADER}" == curl* ]]; then - curl -sSL "${src_url}" -o "${tmpfile}" + http_code=$(curl -sSL -o "${tmpfile}" -w "%{http_code}" "${src_url}") else - wget -q -O "${tmpfile}" "${src_url}" + wget -q -O "${tmpfile}" "${src_url}" || { + rm -f "${tmpfile}" + error "Failed to download from ${src_url}" + return 1 + } + # wget doesn't expose the HTTP code; assume success if no error + http_code="200" fi - # Check that the downloaded content is non-empty and not an HTML error page - if [[ ! -s "${tmpfile}" ]]; then + # Check HTTP status code (curl: exact; wget: best-effort via content) + if [[ "${DOWNLOADER}" == curl* ]] && [[ "${http_code}" != "200" ]]; then rm -f "${tmpfile}" - error "Downloaded empty file from ${src_url}" + error "Server returned HTTP ${http_code} for ${src_url}" return 1 fi - # Gitea returns HTML on 404; detect by checking first bytes - if head -c 100 "${tmpfile}" | grep -qi "