@@ -346,12 +346,17 @@ echo "Step 1: Downloading/updating map data for '${REGION_ID}'..."
346346verify_geofabrik_download () {
347347 local url=" $1 "
348348 local output_file=" $2 "
349+ local checksum_file=" $3 "
349350
350351 case " $url " in
351352 * .osm.pbf)
352353 local expected_checksum
353- expected_checksum=$( wget -qO- " ${url} .md5" | awk ' NR == 1 {print $1}' )
354+ if [ ! -s " $checksum_file " ]; then
355+ wget -qO- " ${url} .md5" | awk ' NR == 1 {print $1}' > " $checksum_file "
356+ fi
357+ expected_checksum=$( cat " $checksum_file " )
354358 if [ -z " $expected_checksum " ] || ! echo " ${expected_checksum} ${output_file} " | md5sum -c -; then
359+ rm -f " $checksum_file "
355360 echo " Error: Geofabrik checksum verification failed for ${output_file##*/ } "
356361 exit 1
357362 fi
@@ -365,15 +370,17 @@ download_with_cache() {
365370 local cached_file=" $3 "
366371 local cache_timestamp_file=" $4 "
367372 local file_type=" $5 "
373+ local checksum_file=" ${cached_file} .md5"
368374
369375 if [ " $file_type " = " true" ]; then
370376 echo " ✅ ${output_file##*/ } is up to date (using cached version)"
371377 cp " $cached_file " " $output_file "
372- verify_geofabrik_download " $url " " $output_file "
378+ verify_geofabrik_download " $url " " $output_file " " $checksum_file "
373379 else
374380 echo " 📥 Downloading ${output_file##*/ } from: ${url} "
375381 if wget -q --show-progress -O " $output_file " " $url " ; then
376- verify_geofabrik_download " $url " " $output_file "
382+ rm -f " $checksum_file "
383+ verify_geofabrik_download " $url " " $output_file " " $checksum_file "
377384 # Cache the downloaded file
378385 cp " $output_file " " $cached_file "
379386 # Store the remote modification date for future comparison
0 commit comments