Updated Download function.
This commit is contained in:
parent
ba2687f8ad
commit
5da5e43964
@ -280,34 +280,63 @@ clear_cache() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
download() {
|
download() {
|
||||||
local source=($@)
|
local source=($@)
|
||||||
for i in "${source[@]}" ; do
|
for i in "${source[@]}" ; do
|
||||||
local dest="${i##*/}"
|
local dest="${i##*/}"
|
||||||
dest="${dest//%20/ }"
|
dest="${dest//%20/ }"
|
||||||
dest="${dest#*\?filename=}"
|
dest="${dest#*\?filename=}"
|
||||||
dest="${dest%\?*}"
|
dest="${dest%\?*}"
|
||||||
# Remove the destination file if it is empty.
|
# Remove the destination file if it is empty.
|
||||||
test -s "${cache}/${dest}" || rm -f "${cache}/${dest}" 2> /dev/null
|
[[ -s "${cache}/${dest}" ]] || rm -f "${cache}/${dest}" 2> /dev/null
|
||||||
if [[ "${redownload}" == "true" ]] && [[ -e "${cache}/${dest}" ]]; then
|
if [[ "${redownload}" == "true" ]] && [[ -e "${cache}/${dest}" ]]; then
|
||||||
rm -v "${cache}/${dest}"
|
rm -v "${cache}/${dest}"
|
||||||
fi
|
fi
|
||||||
# Skip if the item is in cache.
|
# Skip if the item is in cache.
|
||||||
test -e "${cache}/${dest}" && continue
|
[[ -e "${cache}/${dest}" ]] && continue
|
||||||
if ! curl -L4 -C - --retry 10 --output "${cache}/${dest}" "${i}" ; then
|
{ if ! curl -L4 -C - --retry 10 --output "${cache}/${dest}" "${i}" ; then
|
||||||
local exit_code="$?"
|
echo "Could not download \"$i\"..."
|
||||||
if [[ $exit_code -eq 22 ]]; then
|
exit 1
|
||||||
echo "File not found: \"$i\" (HTTP 404)"
|
fi; } | dialog --backtitle "Audio Game Manager" \
|
||||||
# Remove the empty file.
|
--progressbox "Downloading \"$dest\" from \"$i\"" -1 -1
|
||||||
rm -f "${cache}/${dest}"
|
local downloadError=1
|
||||||
exit 1
|
case "${dest##*.}" in
|
||||||
fi
|
"pk3"|"zip")
|
||||||
fi
|
unzip -tq "${cache}/${dest}" | dialog --backtitle "Audio Game Manager" \
|
||||||
if file -b "${cache}/${dest}" | grep -q "HTML document" ; then
|
--progressbox "Validating ${dest##*.} file" -1 -1 --stdout
|
||||||
echo "File not found: \"$i\" (HTML document probably 404)"
|
downloadError=$?
|
||||||
rm -f "${cache}/${dest}"
|
;;
|
||||||
exit 1
|
"7z")
|
||||||
fi
|
7z t "${cache}/${dest}" | dialog --backtitle "Audio Game Manager" \
|
||||||
done
|
--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}"
|
||||||
|
dialog --backtitle "Audio Game Manager" \
|
||||||
|
--infobox "Error downloading \"${dest}\". Installation cannot continue." -1 -1 --stdout
|
||||||
|
alert
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
get_bottle() {
|
get_bottle() {
|
||||||
@ -489,7 +518,7 @@ help() {
|
|||||||
echo "${configFile%/*}/settings.conf"
|
echo "${configFile%/*}/settings.conf"
|
||||||
echo "The syntax is variable=\"value\""
|
echo "The syntax is variable=\"value\""
|
||||||
echo
|
echo
|
||||||
echo "ipfsGateway=\"https://gateway.pinata.cloud\" # Gateway to be used for ipfs downloads."
|
echo "ipfsGateway=\"https://ipfs.stormux.org\" # Gateway to be used for ipfs downloads."
|
||||||
echo "noCache=\"true\" # Do not keep downloaded items in the cache."
|
echo "noCache=\"true\" # Do not keep downloaded items in the cache."
|
||||||
echo "noqjoypad=\"true\" # Do not launch qjoypad."
|
echo "noqjoypad=\"true\" # Do not launch qjoypad."
|
||||||
echo "norh=\"true\" # Do not install RHVoice."
|
echo "norh=\"true\" # Do not install RHVoice."
|
||||||
@ -1155,7 +1184,7 @@ unset noCache
|
|||||||
unset manualInstall
|
unset manualInstall
|
||||||
unset version
|
unset version
|
||||||
# ipfs gateway
|
# ipfs gateway
|
||||||
export ipfsGateway="${ipfsGateway:-https://gateway.pinata.cloud}"
|
export ipfsGateway="${ipfsGateway:-https://ipfs.stormux.org}"
|
||||||
export nvdaControllerClientDll="${ipfsGateway}/ipfs/QmWu7YdSbKMk1Qm5DKvEA5hk1YuAK8wVkwhDf2CsmPkmF1?filename=nvdaControllerClient32.dll"
|
export nvdaControllerClientDll="${ipfsGateway}/ipfs/QmWu7YdSbKMk1Qm5DKvEA5hk1YuAK8wVkwhDf2CsmPkmF1?filename=nvdaControllerClient32.dll"
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user