For Top Speed always try to get a valid download link.
This commit is contained in:
@@ -556,44 +556,56 @@ download() {
|
||||
ui_msgbox "Linux Game Manager" "Linux Game Manager" "Could not download \"$i\"...\n\ndownload exit codes: ${downloadAttemptExitCodes}\nError details: ${downloadErrorLog}"
|
||||
exit 1
|
||||
fi; } | ui_progressbox "Linux Game Manager" "Downloading \"$dest\" from \"$i\""
|
||||
local downloadError=0
|
||||
case "${dest##*.}" in
|
||||
"pk3"|"zip")
|
||||
unzip -tq "${cache}/${dest}" | ui_progressbox "Linux Game Manager" "Validating ${dest##*.} file"
|
||||
downloadError=$?
|
||||
;;
|
||||
"7z")
|
||||
7z t "${cache}/${dest}" | ui_progressbox "Linux Game Manager" "Validating 7z file"
|
||||
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
|
||||
downloadError=1
|
||||
else
|
||||
downloadError=0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
if [[ $downloadError -ne 0 ]]; then
|
||||
rm -fv "${cache}/${dest}"
|
||||
alert "Linux Game Manager" "Linux Game Manager" "Error downloading \"${dest}\". Installation cannot continue."
|
||||
exit 1
|
||||
fi
|
||||
validate_downloaded_cache_file "${dest}"
|
||||
done
|
||||
}
|
||||
|
||||
validate_downloaded_cache_file() {
|
||||
local dest="$1"
|
||||
local downloadError=0
|
||||
case "${dest##*.}" in
|
||||
"pk3"|"zip")
|
||||
if ! (
|
||||
set -o pipefail
|
||||
unzip -tq "${cache}/${dest}" | ui_progressbox "Linux Game Manager" "Validating ${dest##*.} file"
|
||||
); then
|
||||
downloadError=1
|
||||
fi
|
||||
;;
|
||||
"7z")
|
||||
if ! (
|
||||
set -o pipefail
|
||||
7z t "${cache}/${dest}" | ui_progressbox "Linux Game Manager" "Validating 7z file"
|
||||
); then
|
||||
downloadError=1
|
||||
fi
|
||||
;;
|
||||
"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
|
||||
;;
|
||||
*)
|
||||
if file -b "${cache}/${dest}" | grep -q "HTML document" ; then
|
||||
downloadError=1
|
||||
else
|
||||
downloadError=0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
if [[ ${downloadError} -ne 0 ]]; then
|
||||
rm -fv "${cache}/${dest}"
|
||||
alert "Linux Game Manager" "Linux Game Manager" "Error downloading \"${dest}\". Installation cannot continue."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
download_named() {
|
||||
# Only needed if url breaks the name, e.g. downloads/?filename=1234
|
||||
# Required arguments: filename url
|
||||
@@ -614,6 +626,7 @@ download_named() {
|
||||
ui_msgbox "Linux Game Manager" "Linux Game Manager" "Could not download \"$dest\"...\n\ndownload exit codes: ${downloadAttemptExitCodes}\nError details: ${downloadErrorLog}"
|
||||
exit 1
|
||||
fi
|
||||
validate_downloaded_cache_file "${dest}"
|
||||
}
|
||||
|
||||
get_installer() {
|
||||
|
||||
Reference in New Issue
Block a user