From 31ffdbd505636d6e22093750c40dabaa8299ee27 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Sat, 27 Mar 2021 09:26:59 +0100 Subject: [PATCH] local/bin/rget: Fall back to HTTP when rsync fails. --- .local/bin/rget | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.local/bin/rget b/.local/bin/rget index 42d39c26..202096d1 100755 --- a/.local/bin/rget +++ b/.local/bin/rget @@ -62,10 +62,18 @@ rsync*) fi esac +get_wget () { + wget --reject 'index.html*' $OPT_SINGLE --continue --content-disposition --compression=gzip --no-proxy "$1" --directory-prefix="$OUTPUT" +} + mkdir -p "$OUTPUT" if $OPT_HTTP; then - wget --reject 'index.html*' $OPT_SINGLE --continue --content-disposition --compression=gzip --no-proxy "$ADDRESS" --directory-prefix="$OUTPUT" + get_wget "$ADDRESS" else # We ignore timestamp by removing "-t" from "-a". See man page. rsync -ivzzP -rlpgoD --size-only $ADDRESS/files "$OUTPUT" + if [ $? = 5 ]; then + echo "Looks like HTTP, retrying with wget..." + get_wget $(echo "$ADDRESS" | sed s/^rsync/http/) + fi fi