Revert “Also handle retrying curl in this script”
- ID
b9bce73- date
2024-05-09 15:30:07+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
7d55a48- message
Revert "Also handle retrying curl in this script" This reverts commit 031bba617409eee9f99debcc432aafbda16a2632.- changed files
1 file, 8 additions, 52 deletions
Changed files
web/rcurl (1032) → web/rcurl (238)
diff --git a/web/rcurl b/web/rcurl
index 758ebb7..800970b 100755
--- a/web/rcurl
+++ b/web/rcurl
@@ -1,58 +1,14 @@
#!/usr/bin/env bash
-# Download large files with r(esumable) curl.
+# r(esumable) curl.
#
-# This is for large files that can't necessarily be downloaded in one go --
-# it will call curl with a set of flags that allow it to resume an
-# in-progress download, and call it repeatedly until it's done.
+# This just calls curl with a couple of flags that allow it to resume
+# an in-progress download.
set -o errexit
set -o nounset
-if (( $# == 1 ))
-then
- url="$1"
-else
- echo "Usage: $0 URL" >&2
- exit 1
-fi
-
-url="$1"
-
-filename=$(
- curl \
- --location \
- --remote-name \
- --silent \
- --write-out '%{filename_effective}' \
- --head \
- "$url"
-)
-remote_size=$(
- curl \
- --location \
- --head \
- --silent \
- --output /dev/null \
- --write-out '%header{content-length}' \
- "$url"
-)
-
-while true
-do
- curl \
- --location \
- --remote-name \
- --continue-at - \
- "$url" || true
-
- downloaded_size=$(stat -f%z "$filename")
-
- if (( downloaded_size == remote_size ))
- then
- echo "Download complete!"
- exit 0
- else
- echo "*** Download failed before it completed, retrying in 10 seconds..."
- sleep 10
- fi
-done
+curl \
+ --location \
+ --remote-name \
+ --continue-at - \
+ "$1"