summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2015-02-18 11:56:13 +0100
committeremkael <emkael@tlen.pl>2015-02-18 11:56:13 +0100
commiteba0b7e9529dd8eb6702615e6a8c3b2dc092e5bc (patch)
tree2d9f89ba28d159be3766e7768c62943bfbed870d
parent22c4c5580c4c1e24556caf4664b85dec6cbadee9 (diff)
* error handling in fetcher
-rwxr-xr-xfetcher/fetch.sh14
1 files changed, 13 insertions, 1 deletions
diff --git a/fetcher/fetch.sh b/fetcher/fetch.sh
index 259cfc3..9783751 100755
--- a/fetcher/fetch.sh
+++ b/fetcher/fetch.sh
@@ -1,9 +1,21 @@
#!/bin/bash
pushd $(dirname $0) > /dev/null
wget -N http://ergast.com/downloads/f1db.sql.gz -q
+if [[ $? != 0 ]]
+then
+ if [[ -f f1db.sql.gz ]]
+ then
+ echo "Warning: could not fetch new DB, using archived version"
+ else
+ echo "Error: could not fetch DB"
+ popd > /dev/null
+ exit 1
+ fi
+fi
if [[ f1db.sql.gz -nt f1db.sql ]]
then
- echo "New ErgastDB version fetched"
+ echo "Found new ErgastDB version"
zcat f1db.sql.gz | sed 's/ ENGINE=MyISAM//' > f1db.sql
+ find -name f1db.sql.gz -printf '%f: %Td-%Tm-%TY %TH:%TM, %s bytes\n'
fi
popd > /dev/null