From 9e89f6e7b2ca2b720a77fd60b1a25afc49089740 Mon Sep 17 00:00:00 2001 From: Robin Tuszik Date: Mon, 13 Jan 2025 11:01:30 +0100 Subject: [PATCH] refactor: Move disk space check to download_index function --- start-photon.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/start-photon.sh b/start-photon.sh index 9def505..d075ac7 100644 --- a/start-photon.sh +++ b/start-photon.sh @@ -140,6 +140,12 @@ download_index() { mkdir -p "$TEMP_DIR" local url="https://download1.graphhopper.com/public/photon-db-latest" + if [[ -n "${COUNTRY_CODE:-}" ]]; then + url="https://download1.graphhopper.com/public/extracts/by-country-code/${COUNTRY_CODE}/photon-db-${COUNTRY_CODE}-latest" + fi + + # Check disk space before downloading + check_disk_space "$url" url="https://download1.graphhopper.com/public/photon-db-latest" if [[ -n "${COUNTRY_CODE:-}" ]]; then url="https://download1.graphhopper.com/public/extracts/by-country-code/${COUNTRY_CODE}/photon-db-${COUNTRY_CODE}-latest" @@ -281,11 +287,6 @@ interval_to_seconds() { # Main execution main() { mkdir -p "$DATA_DIR" "$TEMP_DIR" - url="https://download1.graphhopper.com/public/photon-db-latest" - if [[ -n "${COUNTRY_CODE:-}" ]]; then - url="https://download1.graphhopper.com/public/extracts/by-country-code/${COUNTRY_CODE}/photon-db-${COUNTRY_CODE}-latest" - fi - check_disk_space "$url" if [ -d "$INDEX_DIR" ]; then if verify_structure "$DATA_DIR"; then