Skip to content

Commit

Permalink
Catch non-200 return codes in download_files.sh
Browse files Browse the repository at this point in the history
Before this commit, the 404 page was saved to the output file and
the script exited with no errors.
  • Loading branch information
eguiraud committed Jul 17, 2020
1 parent 79c82f0 commit e6ee302
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tools/download_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ pushd $OUT_DIR
for FNAME in "$@"; do
echo -n "Downloading ${FNAME}..."
if [[ ! -e "${FNAME}" ]]; then
curl --silent --show-error --remote-name "${BASEURL}/${FNAME}"
HTTP_CODE=$(curl --silent --show-error -w '%{http_code}' --remote-name "${BASEURL}/${FNAME}")
if [[ "${HTTP_CODE}" != "200" ]]; then
echo "There was an error retrieving file '${FNAME}'. HTTP response was ${HTTP_CODE}" 1>&2
rm -f ${FNAME}
exit 3
fi
echo "done"
else
echo "file already present"
Expand Down

0 comments on commit e6ee302

Please sign in to comment.