From: Mischa POSLAWSKY Date: Thu, 12 Feb 2015 05:11:17 +0000 (+0100) Subject: browser: wget-ifmodified script to download new caniuse data X-Git-Tag: v1.7~164 X-Git-Url: http://git.shiar.nl/sheet.git/commitdiff_plain/4048945e110ef0f373ab890e25af7a7d1dac21a9?hp=bc26e655d48aa244c44d5500962324a42b69e97c browser: wget-ifmodified script to download new caniuse data --- diff --git a/Makefile b/Makefile index d7c1003..4e51768 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,9 @@ data/countryInfo.txt: countries.inc.pl: data/countryInfo.txt tools/mkcountries-geonames data/countryInfo.txt >$@ +data/caniuse.json: + tools/wget-ifmodified http://caniuse.com/data.json $@ + clean: -rm digraphs.inc.pl -rm unicode-char.inc.pl diff --git a/tools/wget-ifmodified b/tools/wget-ifmodified new file mode 100755 index 0000000..bae00f1 --- /dev/null +++ b/tools/wget-ifmodified @@ -0,0 +1,26 @@ +#!/usr/bin/env sh + +set -u + +if [ -z "$1" ] +then + echo 'Usage: $0 []' >&2 + # download url to target location if modified + exit 64 # EX_USAGE +fi + +source=$1 +target=${2:-${source##*/}} + +if [ -e "$target" ] +then + modified=$(stat -c%y -L "$target") && + modified=$(date -R -d "$modified") + echo download since: $modified +fi + +headers=${modified:+If-Modified-Since: $modified} +wget -nv --header="$headers" -O "$target.new" "$source" && +mv "$target.new" "$target" || +rm "$target.new" # clean up failed download (usually empty 304 response) +