From 733069bb97bdfe3f9c16ca4c9ef58685205eabf3 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 13 Mar 2012 17:05:22 +0000 Subject: Retry corrupted downloads rather than carrying on almost regardless. Patch mostly due to Michael Gilbert, rearranged somewhat by me (closes: #618920). --- debian/changelog | 8 ++++++++ functions | 54 +++++++++++++++++++++++------------------------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/debian/changelog b/debian/changelog index a3bb1e1..92a77c0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +debootstrap (1.0.39) UNRELEASED; urgency=low + + * Retry corrupted downloads rather than carrying on almost regardless. + Patch mostly due to Michael Gilbert, rearranged somewhat by me (closes: + #618920). + + -- Colin Watson Tue, 13 Mar 2012 17:03:03 +0000 + debootstrap (1.0.38) unstable; urgency=low [ Joey Hess ] 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 -- cgit v0.12