Spaces:
Runtime error

MetaQiu Claude Opus 4.6 commited on
Commit
11d87b1
·
1 Parent(s): 6137734

Use the new GeoCN download URL and validate the downloaded database before replacing the existing file.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. update_and_restart.sh +4 -1
update_and_restart.sh CHANGED
@@ -9,7 +9,10 @@ while true; do
9
  curl -L -o "GeoLite2-ASN.mmdb" "https://github.com/P3TERX/GeoLite.mmdb/raw/download/GeoLite2-ASN.mmdb" || { echo "Failed to update GeoLite2-ASN.mmdb"; continue; }
10
 
11
  echo "Updating GeoCN.mmdb..."
12
- curl -L -o "GeoCN.mmdb" "http://github.com/ljxi/GeoCN/releases/download/Latest/GeoCN.mmdb" || { echo "Failed to update GeoCN.mmdb"; continue; }
 
 
 
13
 
14
  echo "Attempting to restart uvicorn..."
15
  pkill -f "uvicorn"
 
9
  curl -L -o "GeoLite2-ASN.mmdb" "https://github.com/P3TERX/GeoLite.mmdb/raw/download/GeoLite2-ASN.mmdb" || { echo "Failed to update GeoLite2-ASN.mmdb"; continue; }
10
 
11
  echo "Updating GeoCN.mmdb..."
12
+ tmp_geocn="GeoCN.mmdb.tmp"
13
+ curl -L -o "$tmp_geocn" "https://github.com/ljxi/GeoCN/releases/latest/download/GeoCN.mmdb" || { echo "Failed to download GeoCN.mmdb"; rm -f "$tmp_geocn"; continue; }
14
+ python -c "import maxminddb; maxminddb.open_database('$tmp_geocn').close()" || { echo "Downloaded GeoCN.mmdb is invalid"; rm -f "$tmp_geocn"; continue; }
15
+ mv -f "$tmp_geocn" "GeoCN.mmdb"
16
 
17
  echo "Attempting to restart uvicorn..."
18
  pkill -f "uvicorn"