Counting successful map tile fetches.

This commit is contained in:
Roland 2024-12-18 16:39:35 -07:00
parent c2ca5fb3b3
commit 95b3ec3ad2
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680

View file

@ -49,14 +49,37 @@ done
# If we've made it through all attempts, curl never succeeded
if [[ $i -eq $ATTEMPTS ]]; then
echo "Failed to fetch the image after $ATTEMPTS attempts."
echo " You can try resetting your map using /opt/wrolpi/scripts/reset_map.sh then importing a map again."
exit 1
fi
echo "Fetching first map tile succeeded."
curl -ks \
"${HOST}/hot/3/{0..7}/{0..7}.png" \
"${HOST}/hot/4/{0..15}/{0..15}.png" \
"${HOST}/hot/5/{0..31}/{0..31}.png" \
"${HOST}/hot/6/{0..41}/{0..41}.png" >/dev/null 2>&1
echo "Fetching many map tiles completed."
# Function to fetch and count downloads
fetch_and_count() {
local level=$1
local max_x=$2
local max_y=$3
local success_count=0
local failure_count=0
for x in $(seq 0 $max_x); do
for y in $(seq 0 $max_y); do
if wget -q --spider --no-check-certificate "${HOST}/hot/${level}/${x}/${y}.png"; then
((success_count++))
else
((failure_count++))
fi
done
done
echo "Level $level - Successful downloads: $success_count"
}
# Fetch all tiles from each level so the map is ready to use.
fetch_and_count 3 7 7
fetch_and_count 4 15 15
fetch_and_count 5 31 31
fetch_and_count 6 41 41