Fix cache poisoning issue in lh_binary_debian-installer with 404 downloads

When wget 404's, an target file is created - this poisons the cache as the
file is apparently downloaded but in actuality is simply empty. We fix this
by unconditionally deleting the cache file if wget fails and emitting an
error.

Signed-off-by: Chris Lamb <chris@chris-lamb.co.uk>
This commit is contained in:
Chris Lamb 2008-07-26 00:27:29 +01:00
parent 364ed4e362
commit 2435bee4ac

View File

@ -207,7 +207,13 @@ Download_file () {
if [ ! -f "${_LH_CACHE_FILE}" ]
then
mkdir -p ${_LH_CACHE_DIR}
wget ${WGET_OPTIONS} -O "${_LH_CACHE_FILE}" "${_LH_URL}"
if ! wget ${WGET_OPTIONS} -O "${_LH_CACHE_FILE}" "${_LH_URL}"
then
rm -f "${_LH_CACHE_FILE}"
Echo_error "Could not download file: ${_LH_URL}"
exit 1
fi
fi
cp -fl "${_LH_CACHE_FILE}" "${_LH_TARGET}"