From 921e83bb95c55263e0677a7bb45b7bd69fdafd12 Mon Sep 17 00:00:00 2001 From: Martin Nowak Date: Sat, 24 Sep 2016 00:27:36 +0200 Subject: [PATCH] retry fetch to stdout operations - might fails as much as downloads --- script/install.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/script/install.sh b/script/install.sh index b12edd07..52b6c141 100755 --- a/script/install.sh +++ b/script/install.sh @@ -49,13 +49,9 @@ curl() { fi } -# url path -download() { - local url=$1 - local path=$2 - +retry() { for i in {0..4}; do - if curl "$url" -o "$path"; then + if "$@"; then break elif [ $i -lt 4 ]; then sleep $((1 << $i)) @@ -65,12 +61,20 @@ download() { done } +# url path +download() { + local url=$1 + local path=$2 + + retry curl "$url" -o "$path" +} + # url fetch() { local url=$1 local path=$(mktemp "$TMP_ROOT/XXXXXX") - curl2 -sS "$url" -o "$path" + retry curl2 -sS "$url" -o "$path" cat "$path" rm "$path" }