Merge "Improve first time download of ubuntu images."

This commit is contained in:
Jenkins 2013-06-21 13:51:54 +00:00 committed by Gerrit Code Review
commit 539e8e2e69

View File

@ -18,10 +18,20 @@ cache_url()
{
local url=$1
local dest=$2
mkdir -p $(dirname $dest)
local tmp=$(mktemp $(dirname $dest)/.download.XXXXXXXX)
rcode=$(curl -o $tmp -z $dest -w '%{http_code}' $url)
if [ -f $dest ] ; then
time_cond="-z $dest"
success="Server copy has changed. Using server version of $url"
else
success="Downloaded and cached $url for the first time"
fi
rcode=$(curl -o $tmp -w '%{http_code}' $url $time_cond)
if [ "$rcode" == "200" ] ; then
echo "Server copy has changed. Using server version of $url"
echo $success
mv $tmp $dest
elif [ "$rcode" == "304" ] ; then
echo "Server copy has not changed. Using locally cached $url"