Updated Download function.

This commit is contained in:
Storm Dragon 2024-12-14 15:04:41 -05:00
parent 232c6b4dd9
commit 93f5f9177a

View File

@ -205,7 +205,7 @@ download() {
fi
# Skip if the item is in cache.
test -e "${cache}/${dest}" && continue
{ if ! curl -L4 --output "${cache}/${dest}" "${i}" ; then
{ if ! curl -L4 -C - --retry 10 --output "${cache}/${dest}" "${i}" ; then
echo "Could not download \"$i\"..."
exit 1
fi; } | dialog --backtitle "Linux Game Manager" \
@ -215,13 +215,31 @@ download() {
"pk3"|"zip")
unzip -tq "${cache}/${dest}" | dialog --backtitle "Linux Game Manager" \
--progressbox "Validating ${dest##*.} file" -1 -1 --stdout
downloadError= $?
downloadError=$?
;;
"7z")
7z t "${cache}/${dest}" | dialog --backtitle "Linux Game Manager" \
--progressbox "Validating 7z file" -1 -1 --stdout
downloadError=$?
;;
"exe")
# Check if it's a valid Windows executable by looking at the MZ header
if ! hexdump -n 2 -v -e '/1 "%02X"' "${cache}/${dest}" | grep -q "4D5A"; then
downloadError=0
fi
;;
"wad")
if [[ "$(file -b --mime-type "${cache}/${dest}")" != "application/octet-stream" ]]; then
downloadError=0
fi
;;
*)
# Add HTML check for other file types
if file -b "${cache}/${dest}" | grep -q "HTML document" ; then
echo "File not found: \"$i\" (HTML document probably 404)"
downloadError=0
fi
;;
esac
if [[ $downloadError -eq 0 ]]; then
rm -fv "${cache}/${dest}"