Skip to content

Commit e6ee302

Browse files
committed
Catch non-200 return codes in download_files.sh
Before this commit, the 404 page was saved to the output file and the script exited with no errors.
1 parent 79c82f0 commit e6ee302

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tools/download_files.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ pushd $OUT_DIR
3131
for FNAME in "$@"; do
3232
echo -n "Downloading ${FNAME}..."
3333
if [[ ! -e "${FNAME}" ]]; then
34-
curl --silent --show-error --remote-name "${BASEURL}/${FNAME}"
34+
HTTP_CODE=$(curl --silent --show-error -w '%{http_code}' --remote-name "${BASEURL}/${FNAME}")
35+
if [[ "${HTTP_CODE}" != "200" ]]; then
36+
echo "There was an error retrieving file '${FNAME}'. HTTP response was ${HTTP_CODE}" 1>&2
37+
rm -f ${FNAME}
38+
exit 3
39+
fi
3540
echo "done"
3641
else
3742
echo "file already present"

0 commit comments

Comments
 (0)