Skip to content

Commit

Permalink
Change jldownload to use the caching server for all queries.
Browse files Browse the repository at this point in the history
Get rid of `$JLDOWLOAD_PREFER_MIRROR` since the caching server transparently caches now, and falls back to redirecting to the original URL in the case of a cache miss.
Note that we keep a fallback to directly asking for the normal URL in the unlikely event of the cache service completely failing.
  • Loading branch information
staticfloat committed Feb 23, 2015
1 parent 4fc5695 commit e17a259
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions deps/jldownload
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# usage: jldownload [<output-filename>] <url>
#

MIRROR_HOST=https://d304tytmzqn1fl.cloudfront.net
CACHE_HOST=https://cache.e.ip.saba.us

WGET=$(which wget 2>/dev/null)
CURL=$(which curl 2>/dev/null)
Expand All @@ -26,8 +26,7 @@ else
exit 1
fi

MIRROR_BASENAME=`basename $1`
MIRROR_URL="$MIRROR_HOST/$MIRROR_BASENAME"
CACHE_URL="$CACHE_HOST/$2"

if [ -x "$CURL" ] && $CURL -V >/dev/null; then
GETURL="$CURL $CURL_OPTS"
Expand All @@ -41,12 +40,8 @@ else
exit 1
fi

if [ -z "$JLDOWNLOAD_PREFER_MIRROR" ]; then
$GETURL $URL || $GETURL $MIRROR_URL
else
# Still try downloading from the original URL if the mirror fails.
# User may want to get around a single failure, only to run into a dep
# that we haven't mirrored yet, so better to be safe than sorry and try
# the original URL in that case
$GETURL $MIRROR_URL || $GETURL $URL
fi
# Try to get from the cache if it is possible. Note that the cache will
# forward to the original URL if it has not cached this download yet, or
# if the URL is not cacheable. We fallback to directly querying the
# uncached URL to protect against cache service downtime
$GETURL $CACHE_URL || $GETURL $URL

0 comments on commit e17a259

Please sign in to comment.