Skip to content

Commit 0a63189

Browse files
committed
Fix download dump function to support gz files
1 parent 7eb533b commit 0a63189

File tree

2 files changed

+61
-22
lines changed

2 files changed

+61
-22
lines changed

images/full-history/start.sh

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,56 @@ if [ "$OVERWRITE_PLANET_FILE" == "true" ]; then
2525
cloud_planetHistoryPBFFile=planet/planet-history-latest.osm.pbf
2626
fi
2727

28+
2829
# ===============================
2930
# Download db .dump file
3031
# ===============================
3132
download_dump_file() {
32-
echo "Downloading db .dump file from cloud..."
33-
if [ "$CLOUDPROVIDER" == "aws" ]; then
34-
if [[ "$DUMP_CLOUD_URL" == *.txt ]]; then
35-
temp_txt="$VOLUME_DIR/tmp_dump_url.txt"
36-
aws s3 cp "$DUMP_CLOUD_URL" "$temp_txt"
37-
first_line=$(head -n 1 "$temp_txt")
38-
aws s3 cp "$first_line" "$dumpFile"
39-
else
40-
aws s3 cp "$DUMP_CLOUD_URL" "$dumpFile"
41-
fi
42-
elif [ "$CLOUDPROVIDER" == "gcp" ]; then
43-
gsutil cp "$DUMP_CLOUD_URL" "$dumpFile"
44-
fi
33+
echo "Downloading db .dump file from cloud..."
34+
35+
if [ "$CLOUDPROVIDER" == "aws" ]; then
36+
if [[ "$DUMP_CLOUD_URL" == *.txt ]]; then
37+
temp_txt="$VOLUME_DIR/tmp_dump_url.txt"
38+
aws s3 cp "$DUMP_CLOUD_URL" "$temp_txt"
39+
40+
# Get the first line (S3 URL to the .dump or .dump.gz file)
41+
first_line=$(head -n 1 "$temp_txt")
42+
echo "Found dump URL in txt: $first_line"
43+
44+
# Set dump file name based on extension
45+
if [[ "$first_line" == *.gz ]]; then
46+
dumpFile="${dumpFile}.gz"
47+
fi
48+
49+
aws s3 cp "$first_line" "$dumpFile"
50+
if [[ "$dumpFile" == *.gz ]]; then
51+
echo "Decompressing gzip file..."
52+
gunzip -f "$dumpFile"
53+
dumpFile="${dumpFile%.gz}"
54+
fi
55+
rm -f "$temp_txt"
56+
57+
else
58+
# Set dump file name based on extension
59+
if [[ "$DUMP_CLOUD_URL" == *.gz ]]; then
60+
dumpFile="${dumpFile}.gz"
61+
fi
62+
aws s3 cp "$DUMP_CLOUD_URL" "$dumpFile"
63+
if [[ "$dumpFile" == *.gz ]]; then
64+
echo "Decompressing gzip file..."
65+
gunzip -f "$dumpFile"
66+
dumpFile="${dumpFile%.gz}"
67+
fi
68+
fi
69+
70+
elif [ "$CLOUDPROVIDER" == "gcp" ]; then
71+
gsutil cp "$DUMP_CLOUD_URL" "$dumpFile"
72+
else
73+
echo "Unsupported CLOUDPROVIDER: $CLOUDPROVIDER"
74+
exit 1
75+
fi
76+
77+
echo "Dump file ready at: $dumpFile"
4578
}
4679

4780
# ===============================

images/planet-dump/start.sh

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,36 +23,42 @@ if [ "$OVERWRITE_PLANET_FILE" == "true" ]; then
2323
cloud_planetPBFFile=planet/planet-latest.osm.pbf
2424
fi
2525

26-
# ===============================
27-
# Download db .dump file
28-
# ===============================
26+
2927
# ===============================
3028
# Download db .dump file
3129
# ===============================
3230
download_dump_file() {
3331
echo "Downloading db .dump file from cloud..."
32+
3433
if [ "$CLOUDPROVIDER" == "aws" ]; then
3534
if [[ "$DUMP_CLOUD_URL" == *.txt ]]; then
36-
# Download the .txt file containing the URL
3735
temp_txt="$VOLUME_DIR/tmp_dump_url.txt"
3836
aws s3 cp "$DUMP_CLOUD_URL" "$temp_txt"
3937

4038
# Get the first line (S3 URL to the .dump or .dump.gz file)
4139
first_line=$(head -n 1 "$temp_txt")
4240
echo "Found dump URL in txt: $first_line"
4341

44-
aws s3 cp "$first_line" "$dumpFile"
45-
46-
# Check if it's compressed (.gz) and decompress
42+
# Set dump file name based on extension
4743
if [[ "$first_line" == *.gz ]]; then
44+
dumpFile="${dumpFile}.gz"
45+
fi
46+
47+
aws s3 cp "$first_line" "$dumpFile"
48+
if [[ "$dumpFile" == *.gz ]]; then
4849
echo "Decompressing gzip file..."
4950
gunzip -f "$dumpFile"
5051
dumpFile="${dumpFile%.gz}"
5152
fi
53+
rm -f "$temp_txt"
54+
5255
else
53-
aws s3 cp "$DUMP_CLOUD_URL" "$dumpFile"
54-
# If it's compressed, decompress
56+
# Set dump file name based on extension
5557
if [[ "$DUMP_CLOUD_URL" == *.gz ]]; then
58+
dumpFile="${dumpFile}.gz"
59+
fi
60+
aws s3 cp "$DUMP_CLOUD_URL" "$dumpFile"
61+
if [[ "$dumpFile" == *.gz ]]; then
5662
echo "Decompressing gzip file..."
5763
gunzip -f "$dumpFile"
5864
dumpFile="${dumpFile%.gz}"

0 commit comments

Comments
 (0)