@cryptotaxi247 / kubo / commits / f21499f44

Make dist_get fallback to other downloaders if one fails

License: MIT Signed-off-by: Mateusz Naściszewski <matin1111@wp.pl>

mateon1 committed Feb 15, 2017 at 21:54 UTC f21499f4498634110d649ed10acdd7f6fb5ef3e2
1 file changed +17 -8
bin/dist_get
+17 -8
@@ -25,17 +25,26 @@ download() {
25
26 if have_binary wget; then
27 printf '==> Using wget to download "%s" to "%s"\n' "$dl_url" "$dl_output"
28 - wget "$dl_url" -O "$dl_output" || return
29 - elif have_binary curl; then
28 + if wget "$dl_url" -O "$dl_output"; then
29 + echo "==> download complete!"
30 + return
31 + fi
32 + fi
33 + if have_binary curl; then
34 printf '==> Using curl to download "%s" to "%s"\n' "$dl_url" "$dl_output"
31 - curl --silent "$dl_url" > "$dl_output" || return
32 - elif have_binary fetch; then
35 + if curl --silent "$dl_url" > "$dl_output"; then
36 + echo "==> download complete!"
37 + return
38 + fi
39 + fi
40 + if have_binary fetch; then
41 printf '==> Using fetch to download "%s" to "%s"\n' "$dl_url" "$dl_output"
34 - fetch "$dl_url" -o "$dl_output" || return
35 - else
36 - die "no binary found to download $dl_url. exiting."
42 + if fetch "$dl_url" -o "$dl_output"; then
43 + echo "==> download complete!"
44 + return
45 + fi
46 fi
38 - echo "==> download complete!"
47 + die "Unable to download $dl_url. exiting."
48 }
49
50 unarchive() {