summaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2012-03-13 17:05:22 +0000
committerColin Watson <cjwatson@debian.org>2012-03-13 17:05:22 +0000
commit733069bb97bdfe3f9c16ca4c9ef58685205eabf3 (patch)
tree8ae399a1fa0e84da15a312de559bde21f8ee297d /functions
parent412608c1fbe28074f56d930242e4269d5588d101 (diff)
downloaddebootstrap-733069bb97bdfe3f9c16ca4c9ef58685205eabf3.tar.gz
Retry corrupted downloads rather than carrying on almost regardless. Patch mostly due to Michael Gilbert, rearranged somewhat by me (closes: #618920).
Diffstat (limited to 'functions')
-rw-r--r--functions54
1 files changed, 23 insertions, 31 deletions
diff --git a/functions b/functions
index 18835bd..a8fdce4 100644
--- a/functions
+++ b/functions
@@ -315,6 +315,7 @@ get () {
local typ="$(eval echo \${$(( $a+2 ))})"
local from
local dest
+ local iters=0
case "$typ" in
bz2) from="$1.bz2"; dest="$2.bz2" ;;
@@ -330,24 +331,29 @@ get () {
dest2="${dest2%/*}/partial/${dest2##*/}"
fi
- info RETRIEVING "Retrieving %s" "$displayname"
- if ! just_get "$from" "$dest2"; then continue; fi
- if [ "$checksum" != "" ]; then
- info VALIDATING "Validating %s" "$displayname"
- if verify_checksum "$dest2" "$checksum" "$siz"; then
- checksum=""
+ while [ "$iters" -lt 10 ]; do
+ info RETRIEVING "Retrieving %s" "$displayname"
+ if ! just_get "$from" "$dest2"; then continue 2; fi
+ if [ "$checksum" != "" ]; then
+ info VALIDATING "Validating %s" "$displayname"
+ if verify_checksum "$dest2" "$checksum" "$siz"; then
+ checksum=""
+ fi
fi
- fi
- if [ -z "$checksum" ]; then
- [ "$dest2" = "$dest" ] || mv "$dest2" "$dest"
- case "$typ" in
- gz) gunzip "$dest" ;;
- bz2) bunzip2 "$dest" ;;
- esac
- return 0
- else
- warning CORRUPTFILE "%s was corrupt" "$from"
- fi
+ if [ -z "$checksum" ]; then
+ [ "$dest2" = "$dest" ] || mv "$dest2" "$dest"
+ case "$typ" in
+ gz) gunzip "$dest" ;;
+ bz2) bunzip2 "$dest" ;;
+ esac
+ return 0
+ else
+ rm -f "$dest2"
+ warning RETRYING "Retrying failed download of %s" "$from"
+ iters="$(($iters + 1))"
+ fi
+ done
+ warning CORRUPTFILE "%s was corrupt" "$from"
done
return 1
}
@@ -363,13 +369,6 @@ just_get () {
# http/ftp mirror
if wgetprogress -O "$dest" "$from"; then
return 0
- elif [ -s "$dest" ]; then
- local iters=0
- while [ "$iters" -lt 3 ]; do
- warning RETRYING "Retrying failed download of %s" "$from"
- if wgetprogress -c -O "$dest" "$from"; then break; fi
- iters="$(($iters + 1))"
- done
else
rm -f "$dest"
return 1
@@ -378,13 +377,6 @@ just_get () {
# http/ftp mirror
if wgetprogress $CHECKCERTIF $CERTIFICATE $PRIVATEKEY -O "$dest" "$from"; then
return 0
- elif [ -s "$dest" ]; then
- local iters=0
- while [ "$iters" -lt 3 ]; do
- warning RETRYING "Retrying failed download of %s" "$from"
- if wgetprogress $CHECKCERTIF $CERTIFICATE $PRIVATEKEY -c -O "$dest" "$from"; then break; fi
- iters="$(($iters + 1))"
- done
else
rm -f "$dest"
return 1