Refactor aria2c and zsync support

If aria2 is installed, it will now be listed in the csv/json
pull/373/head
Martin Wimpress 3 years ago
parent 5f26733687
commit 559e2ae886
No known key found for this signature in database
GPG Key ID: 61DF940515E06DA3
  1. 39
      quickget

@ -89,6 +89,7 @@ function list_json() {
function list_csv() { function list_csv() {
local DISPLAY_NAME local DISPLAY_NAME
local DL=""
local DOWNLOADER local DOWNLOADER
local FUNC local FUNC
local OPTION local OPTION
@ -96,16 +97,19 @@ function list_csv() {
local PNG local PNG
local RELEASE local RELEASE
local SVG local SVG
local ZS="" local HAS_ZSYNC=0
local DL=""
# Check if zsync is available
if command -v zsync &>/dev/null; then
HAS_ZSYNC=1
fi
# check if we have a zsync installed somewhere if command -v aria2c &>/dev/null; then
ZS="$(which zsync)" DL="aria2c"
if [ -x "${ZS}" ]; then elif command -v wget &>/dev/null; then
DL="zsync"
else
DL="wget" DL="wget"
fi fi
echo "Display Name,OS,Release,Option,Downloader,PNG,SVG" echo "Display Name,OS,Release,Option,Downloader,PNG,SVG"
for OS in $(os_support); do for OS in $(os_support); do
DISPLAY_NAME="$(pretty_name "${OS}")" DISPLAY_NAME="$(pretty_name "${OS}")"
@ -120,12 +124,12 @@ function list_csv() {
for RELEASE in $("releases_${FUNC}"); do for RELEASE in $("releases_${FUNC}"); do
if [ "${OS}" == "macos" ]; then if [ "${OS}" == "macos" ]; then
DOWNLOADER="macrecovery" DOWNLOADER="macrecovery"
elif [ "${OS}" == "ubuntu" ] && [ "${RELEASE}" == "canary" ]; then elif [ "${OS}" == "ubuntu" ] && [ "${RELEASE}" == "canary" ] && [ ${HAS_ZSYNC} -eq 1 ]; then
DOWNLOADER="${DL}" DOWNLOADER="zsync"
elif [[ "${OS}" == *"ubuntu"* ]] && [ "${RELEASE}" == "devel" ]; then elif [[ "${OS}" == *"ubuntu"* ]] && [ "${RELEASE}" == "devel" ] && [ ${HAS_ZSYNC} -eq 1 ]; then
DOWNLOADER="${DL}" DOWNLOADER="zsync"
else else
DOWNLOADER="wget" DOWNLOADER="${DL}"
fi fi
if [ "${OS}" == "windows" ]; then if [ "${OS}" == "windows" ]; then
@ -518,7 +522,7 @@ function web_get() {
exit 1 exit 1
fi fi
if command -v aria2c > /dev/null; then if command -v aria2c &>/dev/null; then
if ! aria2c -x16 --continue=true --summary-interval=0 --download-result=hide --console-log-level=error "${URL}" -o "${DIR}/${FILE}"; then if ! aria2c -x16 --continue=true --summary-interval=0 --download-result=hide --console-log-level=error "${URL}" -o "${DIR}/${FILE}"; then
echo #Necessary as aria2c in suppressed mode does not have new lines echo #Necessary as aria2c in suppressed mode does not have new lines
echo "ERROR! Failed to download ${URL} with aria2c. Try running 'quickget' again." echo "ERROR! Failed to download ${URL} with aria2c. Try running 'quickget' again."
@ -538,12 +542,11 @@ function zsync_get() {
local FILE="" local FILE=""
local OUT="" local OUT=""
local URL="${1}" local URL="${1}"
FILE="${URL##*/}"
local ZS="" local ZS=""
# check if we have a zsync installed somewhere FILE="${URL##*/}"
ZS="$(which zsync)"
if [ -x "${ZS}" ]; then if command -v zsync &>/dev/null; then
if [ -n "${3}" ]; then if [ -n "${3}" ]; then
OUT="${3}" OUT="${3}"
else else
@ -564,7 +567,7 @@ function zsync_get() {
rm "${DIR}/${OUT}.zs-old" rm "${DIR}/${OUT}.zs-old"
fi fi
else else
echo "INFO: zsync not found, falling back to wget" echo "INFO: zsync not found, falling back to wget/aria2c"
web_get "${ISO}" "${DIR}" web_get "${ISO}" "${DIR}"
fi fi
} }

Loading…
Cancel
Save