Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(ci): Download to temp file before decompressing (#62782)

mendral-app[bot]9f6a89d47c1c
diff --git a/bin/download-mmdb b/bin/download-mmdb
index 64bf7a2b11be..0a49eb76df44 100755
--- a/bin/download-mmdb
+++ b/bin/download-mmdb
@@ -10,6 +10,9 @@ mkdir -p "$DIR/../share"
if [ ! -f "$DIR/../share/GeoLite2-City.mmdb" ] || [ ! -f "$DIR/../share/GeoLite2-City.json" ]; then
rm -f "$DIR/../share/GeoLite2-City.mmdb" "$DIR/../share/GeoLite2-City.json"
+ TMPFILE=$(mktemp)
+ trap 'rm -f "$TMPFILE"' EXIT
+
echo "Downloading GeoLite2-City.mmdb..."
if curl -L "https://mmdbcdn.posthog.net/" \
--http1.1 \
@@ -18,9 +21,10 @@ if [ ! -f "$DIR/../share/GeoLite2-City.mmdb" ] || [ ! -f "$DIR/../share/GeoLite2
--retry-max-time 300 \
--retry-all-errors \
--progress-bar \
- --show-error |
- brotli --decompress --output="$DIR/../share/GeoLite2-City.mmdb"; then
- echo "Download successful"
+ --show-error \
+ --output "$TMPFILE"; then
+ echo "Download successful, decompressing..."
+ brotli --decompress --output="$DIR/../share/GeoLite2-City.mmdb" "$TMPFILE"
else
echo "Download failed after retries"
exit 1