local/bin/rget: Fall back to HTTP when rsync fails.

master
Pierre Neidhardt 2021-03-27 09:26:59 +01:00
parent f1d7419c3a
commit 31ffdbd505
1 changed files with 9 additions and 1 deletions

View File

@ -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