mirror of
				https://github.com/oSoWoSo/DistroHopper.git
				synced 2024-08-14 22:46:53 +00:00 
			
		
		
		
	Fix 212 Fallback to wget if zsync not available (#214)
* first shot at falling back to wget * add fallback to list function * whitespace * Better message and shellcheck pacification
This commit is contained in:
		
							parent
							
								
									d3506d1c4a
								
							
						
					
					
						commit
						f19b84afeb
					
				
					 1 changed files with 37 additions and 18 deletions
				
			
		
							
								
								
									
										55
									
								
								quickget
									
										
									
									
									
								
							
							
						
						
									
										55
									
								
								quickget
									
										
									
									
									
								
							|  | @ -89,6 +89,16 @@ function list_csv() { | ||||||
|   local OPTION |   local OPTION | ||||||
|   local OS |   local OS | ||||||
|   local RELEASE |   local RELEASE | ||||||
|  |   local ZS="" | ||||||
|  |   local DL="" | ||||||
|  | 
 | ||||||
|  | # check if we have a zsync installed somewhere | ||||||
|  |   ZS="$(which zsync)" | ||||||
|  |   if  [ -x "${ZS}" ]; then | ||||||
|  |     DL="zsync" | ||||||
|  |   else | ||||||
|  |     DL="wget" | ||||||
|  |   fi | ||||||
|   echo "Display Name,OS,Release,Option,Downloader" |   echo "Display Name,OS,Release,Option,Downloader" | ||||||
|   for OS in $(os_support); do |   for OS in $(os_support); do | ||||||
|     DISPLAY_NAME="$(pretty_name "${OS}")" |     DISPLAY_NAME="$(pretty_name "${OS}")" | ||||||
|  | @ -106,13 +116,13 @@ function list_csv() { | ||||||
|       if [ "${OS}" == "macos" ]; then |       if [ "${OS}" == "macos" ]; then | ||||||
|         DOWNLOADER="macrecovery" |         DOWNLOADER="macrecovery" | ||||||
|       elif [ "${OS}" == "ubuntu" ] && [ "${RELEASE}" == "canary" ]; then |       elif [ "${OS}" == "ubuntu" ] && [ "${RELEASE}" == "canary" ]; then | ||||||
|         DOWNLOADER="zsync" |         DOWNLOADER="${DL}" | ||||||
|       elif [[ "${OS}" == *"ubuntu"* ]] && [ "${RELEASE}" == "devel" ]; then |       elif [[ "${OS}" == *"ubuntu"* ]] && [ "${RELEASE}" == "devel" ]; then | ||||||
|         DOWNLOADER="zsync" |         DOWNLOADER="${DL}" | ||||||
|       elif [ "${OS}" == "garuda" ]; then |       elif [ "${OS}" == "garuda" ]; then | ||||||
|         DOWNLOADER="zsync" |         DOWNLOADER="${DL}" | ||||||
|       elif [[ "${OS}" == *"kdeneon"* ]]; then |       elif [[ "${OS}" == *"kdeneon"* ]]; then | ||||||
|         DOWNLOADER="zsync" |         DOWNLOADER="${DL}" | ||||||
|       else |       else | ||||||
|         DOWNLOADER="wget" |         DOWNLOADER="wget" | ||||||
|       fi |       fi | ||||||
|  | @ -597,24 +607,33 @@ function zsync_get() { | ||||||
|     local OUT="" |     local OUT="" | ||||||
|     local URL="${1}" |     local URL="${1}" | ||||||
|     FILE="${URL##*/}" |     FILE="${URL##*/}" | ||||||
|     if [ -n "${3}" ]; then |     local ZS="" | ||||||
|         OUT="${3}" |  | ||||||
|     else |  | ||||||
|         OUT="${FILE}" |  | ||||||
|     fi |  | ||||||
| 
 | 
 | ||||||
|     if ! mkdir -p "${DIR}" 2>/dev/null; then | # check if we have a zsync installed somewhere | ||||||
|       echo "ERROR! Unable to create directory ${DIR}" |   ZS="$(which zsync)" | ||||||
|       exit 1 |     if  [ -x "${ZS}" ]; then | ||||||
|     fi |       if [ -n "${3}" ]; then | ||||||
|  |           OUT="${3}" | ||||||
|  |       else | ||||||
|  |           OUT="${FILE}" | ||||||
|  |       fi | ||||||
| 
 | 
 | ||||||
|     if ! zsync "${URL}.zsync" -i "${DIR}/${OUT}" -o "${DIR}/${OUT}" 2>/dev/null; then |       if ! mkdir -p "${DIR}" 2>/dev/null; then | ||||||
|         echo "ERROR! Failed to download ${URL}.zsync" |         echo "ERROR! Unable to create directory ${DIR}" | ||||||
|         exit 1 |         exit 1 | ||||||
|     fi |       fi | ||||||
| 
 | 
 | ||||||
|     if [ -e "${DIR}/${OUT}.zs-old" ]; then |       if ! zsync "${URL}.zsync" -i "${DIR}/${OUT}" -o "${DIR}/${OUT}" 2>/dev/null; then | ||||||
|         rm "${DIR}/${OUT}.zs-old" |           echo "ERROR! Failed to download ${URL}.zsync" | ||||||
|  |           exit 1 | ||||||
|  |       fi | ||||||
|  | 
 | ||||||
|  |       if [ -e "${DIR}/${OUT}.zs-old" ]; then | ||||||
|  |           rm "${DIR}/${OUT}.zs-old" | ||||||
|  |       fi | ||||||
|  |     else | ||||||
|  |       echo "INFO: zsync not found, falling back to wget" | ||||||
|  |       web_get "${ISO}" | ||||||
|     fi |     fi | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue