Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #loop until FULL_FILE is set in fetch_blob.. this is for bad/slow connections
- while [ "$FULL_FILE" != "1" ];do
- local token="$(curl -fsSL "$authBase/token?service=$authService&scope=repository:$image:pull" | jq --raw-output '.token')"
- fetch_blob "$token" "$image" "$layerDigest" "$dir/$layerTar" --progress
- sleep 1
- done
- while :; do
- #if the file already exists.. we will be resuming..
- if [ -f "$targetFile" ];then
- #getting current size of file we are resuming
- CUR=`stat --printf="%s" $targetFile`
- #use curl to get headers to find content-length of the full file
- LEN=`curl -I -fL "${curlArgs[@]}" "$blobRedirect"|grep content-length|cut -d" " -f2`
- #if we already have the entire file... lets stop curl from erroring with 416
- if [ "$CUR" == "${LEN//[!0-9]/}" ]; then
- FULL_FILE=1
- break
- fi
- fi
- HTTP_CODE=`curl -w %{http_code} -C - --tr-encoding --compressed --progress-bar -fL "${curlArgs[@]}" "$blobRedirect" -o "$targetFile"`
- if [ "$HTTP_CODE" == "403" ]; then
- #token expired so the server stopped allowing us to resume, lets return without setting FULL_FILE and itll restart this func w new token
- FULL_FILE=0
- break
- fi
- if [ "$HTTP_CODE" == "416" ]; then
- FULL_FILE=1
- break
- fi
- sleep 1
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement