]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/taginfo/templates/default/update-planet.erb
Make taginfo handle planet updates that need multiple passes correctly
[chef.git] / cookbooks / taginfo / templates / default / update-planet.erb
index 76b7af27364d063a1fd3fc3f9aaac35badf768ea..50e058632a8d9167ea832cd481d4c37bcf0c5c5c 100644 (file)
@@ -2,41 +2,37 @@
 
 # DO NOT EDIT - This file is being maintained by Chef
 
-# abort on error
-
-set -e
-
 # setup
 
 PLANETDIR="<%= @directory %>/planet"
 LOGDIR="${PLANETDIR}/log"
-PLANETOLD="${PLANETDIR}/planet.pbf"
+PLANETPREV="${PLANETDIR}/planet-previous.pbf"
+PLANETCURR="${PLANETDIR}/planet.pbf"
 PLANETNEW="${PLANETDIR}/planet-new.pbf"
-STATEDIR="${PLANETDIR}/replication"
-OSCFILE="${PLANETDIR}/$(date +%Y%m%d-%H%M).osc"
+PLANETTMP="${PLANETDIR}/planet-tmp.pbf"
 
 # start logging
 
 exec > "${LOGDIR}/$(date +%Y%m%d-%H%M).log" 2>&1
 
-# if there are old .osc files, they have to be taken into account
+pyosmium-up-to-date -v -o $PLANETNEW $PLANETCURR
+retval=$?
 
-OLDFILE="$(find "${PLANETDIR}" -name "2*-*.osc" -print)"
-if [ -z "$OLDFILE" ]
-then
-   osmosis --rri "$STATEDIR" --simc --write-xml-change "$OSCFILE"
-else
-   osmosis --rxc "$OLDFILE" --rri "$STATEDIR" --mc --simc --write-xml-change "$OSCFILE" && rm "$OLDFILE"
-fi
+while [ $retval -eq 1 ]; do
+    mv "$PLANETNEW" "$PLANETTMP"
+    pyosmium-up-to-date -v -o $PLANETNEW $PLANETTMP
+    retval=$?
+    rm "$PLANETTMP"
+done
 
-# osc file is ready, create new planet file
-
-osmosis --read-xml-change "$OSCFILE" --read-bin "$PLANETOLD" --buffer bufferCapacity=12000 --apply-change --buffer bufferCapacity=12000 --write-pbf file="$PLANETNEW"
+if [ $retval -ne 0 ]; then
+  exit $retval
+fi
 
 # cleanup
 
-mv "$PLANETNEW" "$PLANETOLD"
-rm "$OSCFILE"
+mv "$PLANETCURR" "$PLANETPREV"
+mv "$PLANETNEW" "$PLANETCURR"
 
 # expire old logs