Commit fc5df947 authored by Nils Goroll's avatar Nils Goroll

improve download of dcs.db

avoid unnecessary downloads and rebuilds
improve handling of download errors
make 'make load' work
parent a6ad7016
......@@ -28,17 +28,32 @@ fixup-local: fixup.remove fixup.reorder fixup.out
load-local: dcs.db.refresh dcs.db
dcs.db.tstamp:
touch dcs.db.tstamp
dcs.db.refresh:
touch dcs.db.refresh
-rm dcs.db.tstamp
.PHONY: dcs.db.refresh
# note on the diff/rm/ln logic below:
# if the dcs.db has not changed, we do not want to rebuild, so we
# do not want to change its timestamp.
dcs.db: dcs.db.refresh
curl -H 'Content-Type: application/json' \
dcs.db: dcs.db.tstamp
curl -f -H 'Content-Type: application/json' \
-d '{"profile":"", "uri":"/ds/classifier/get/account/'$(DCS_ACCOUNT)'", "token":"'$(DCS_KEY)'"}' \
'https://dcs.netbiscuits.net/ds/classifier/get/account/'$(DCS_ACCOUNT) \
> dcs.db.tmp
if [[ -f dcs.db ]] ; then \
test -s dcs.db.tmp
if test -f dcs.db ; then \
if ! diff --brief dcs.db dcs.db.tmp >/dev/null ; then \
mv -f dcs.db.tmp dcs.db ; \
else \
rm dcs.db.tstamp ; \
ln dcs.db dcs.db.tstamp ; \
fi ; \
else \
mv -f dcs.db.tmp dcs.db ; \
......@@ -51,4 +66,5 @@ CLEANFILES = \
fixup.remove \
fixup.reorder \
fixup.out \
dcs.db
\ No newline at end of file
dcs.db \
dcs.db.tstamp
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment