From f78e68286eecb40391cb4b37e87b80c21209b950 Mon Sep 17 00:00:00 2001 From: Alexey Zakharenkov Date: Fri, 26 Jul 2019 10:54:58 +0300 Subject: [PATCH] osmupdate tool returns 0 code on some kind of failures, so analyze its stderr to avoid proceeding with corrupted planet --- scripts/process_subways.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/process_subways.sh b/scripts/process_subways.sh index 82e01e6..2d0a5b5 100755 --- a/scripts/process_subways.sh +++ b/scripts/process_subways.sh @@ -34,14 +34,14 @@ if [ ! -f "$OSMCTOOLS/osmupdate" ]; then OSMCTOOLS="$(dirname "$(which osmupdate)")" else echo "Please compile osmctools to $OSMCTOOLS" - exit 1 + exit 3 fi fi PYTHON=${PYTHON:-python3} # This will fail if there is no python "$PYTHON" --version > /dev/null SUBWAYS_PATH="$(dirname "$0")/.." -[ ! -f "$SUBWAYS_PATH/process_subways.py" ] && echo "Please clone the subways repo to $SUBWAYS_PATH" && exit 2 +[ ! -f "$SUBWAYS_PATH/process_subways.py" ] && echo "Please clone the subways repo to $SUBWAYS_PATH" && exit 4 TMPDIR="${TMPDIR:-$SUBWAYS_PATH}" # Downloading the latest version of the subways script @@ -56,11 +56,15 @@ if [ -n "${GIT_PULL-}" ]; then ( # Updating the planet file PLANET_ABS="$(cd "$(dirname "$PLANET")"; pwd)/$(basename "$PLANET")" -( - cd "$OSMCTOOLS" # osmupdate requires osmconvert in a current directory - ./osmupdate --drop-author --out-o5m "$PLANET_ABS" ${BBOX+"-b=$BBOX"} "$PLANET_ABS.new.o5m" - mv "$PLANET_ABS.new.o5m" "$PLANET_ABS" -) +pushd "$OSMCTOOLS" # osmupdate requires osmconvert in a current directory +OSMUPDATE_ERRORS=$(./osmupdate --drop-author --out-o5m "$PLANET_ABS" ${BBOX+"-b=$BBOX"} "$PLANET_ABS.new.o5m" 2>&1) +if [ -n "$OSMUPDATE_ERRORS" ]; then + echo "osmupdate failed: $OSMUPDATE_ERRORS" + exit 5 +fi +popd +mv "$PLANET_ABS.new.o5m" "$PLANET_ABS" + # Filtering it