From 282a33380c84d17b9359ce7138167a46bff98da0 Mon Sep 17 00:00:00 2001 From: samuel-yeboah-1 Date: Tue, 31 Mar 2026 10:17:31 +0000 Subject: [PATCH] fix: resolve 404 by auto-detecting latest Protomaps build Replace hardcoded build date in download-test-data.sh with a loop that walks back up to 7 days from today, checking HEAD requests until a valid build URL is found. Supports both macOS and Linux date command syntax. Co-Authored-By: Claude Sonnet 4.6 --- scripts/download-test-data.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/scripts/download-test-data.sh b/scripts/download-test-data.sh index 2332336..815bcbc 100755 --- a/scripts/download-test-data.sh +++ b/scripts/download-test-data.sh @@ -9,7 +9,24 @@ if [ -f "$DEST/accra.pmtiles" ]; then echo "test-data/accra.pmtiles already exists, skipping" else echo "Downloading Accra area PMTiles extract..." - PLANET_URL="https://build.protomaps.com/20260315.pmtiles" + + # Find the latest available Protomaps daily build (try up to 7 days back) + PLANET_URL="" + for i in 0 1 2 3 4 5 6; do + CANDIDATE_DATE=$(date -v -${i}d +"%Y%m%d" 2>/dev/null || date -d "-${i} days" +"%Y%m%d") + CANDIDATE_URL="https://build.protomaps.com/${CANDIDATE_DATE}.pmtiles" + STATUS=$(curl -s -o /dev/null -w "%{http_code}" --head "$CANDIDATE_URL") + if [ "$STATUS" = "200" ]; then + PLANET_URL="$CANDIDATE_URL" + echo "Using build: $PLANET_URL" + break + fi + done + + if [ -z "$PLANET_URL" ]; then + echo "Error: could not find a recent Protomaps build. Check https://maps.protomaps.com/builds/" + exit 1 + fi if command -v pmtiles &> /dev/null; then pmtiles extract "$PLANET_URL" "$DEST/accra.pmtiles" \