From e96e34f6ffcdb7dd85347599ab0a5509e042280e Mon Sep 17 00:00:00 2001 From: Ducky Date: Tue, 26 Sep 2023 04:13:53 +0100 Subject: [PATCH] osm-garmin: improve performance --- osm-garmin/app/build-gmap.sh | 11 ++++++----- osm-garmin/app/daemon.sh | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/osm-garmin/app/build-gmap.sh b/osm-garmin/app/build-gmap.sh index 71c5c58..307c0cb 100755 --- a/osm-garmin/app/build-gmap.sh +++ b/osm-garmin/app/build-gmap.sh @@ -87,7 +87,7 @@ function update_bounds() { } download_bounds "bounds" - download_bounds "sea" + #download_bounds "sea" } function update_osm_map() { @@ -121,8 +121,6 @@ regions_array="$(echo $regions | tr ";" "\n")" for region in $regions_array; do if [[ "$(check_osm_region_exists "$region")" == "true" ]]; then - echo "👀 Checking OSM updates: $region" - if [[ "$(check_osm_update "$region")" == "true" ]]; then echo "🌍 Updating OSM map: $region" update_osm_map "$region" @@ -135,13 +133,16 @@ for region in $regions_array; do fi done +# TODO: Don't update this if there wasn't any updates echo "📒 Updating bounds..." update_bounds for region in $regions_array; do if [[ "$(check_osm_region_exists "$region")" == "true" ]]; then - echo "🔨 Building Garmin map: $region" - build_gmap "$region" "$style" + if [[ "$(check_osm_update "$region")" == "true" ]]; then + echo "🔨 Building Garmin map: $region" + build_gmap "$region" "$style" + fi else echo "⚠️ Region \"$region\" does not exist" fi diff --git a/osm-garmin/app/daemon.sh b/osm-garmin/app/daemon.sh index 9bd4ecc..0f4b669 100644 --- a/osm-garmin/app/daemon.sh +++ b/osm-garmin/app/daemon.sh @@ -3,6 +3,13 @@ . /app/utils.sh sleep_time=3600 +sleep_time_fail=60 + +function wait() { + delay="$1" + echo "💤 Sleeping $delay seconds..." + sleep $delay +} while : do @@ -14,6 +21,9 @@ do /app/build-gmap.sh "$regions" "$style" - echo "💤 Sleeping $sleep_time seconds..." - sleep $sleep_time + if [[ $? == 0 ]]; then + wait $sleep_time + else + wait $sleep_time_fail + fi done \ No newline at end of file