Skip to content

Commit

Permalink
hackage: Download snapshot first
Browse files Browse the repository at this point in the history
  • Loading branch information
taoky committed Dec 28, 2024
1 parent cf2948d commit cc6814f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion hackage/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ function pull_hackage () {
rm index.tar.gz || true &> /dev/null
rm index-00.tar.gz || true &> /dev/null

# snapshot.json contains hashes of 01-index.tar.gz
# Download it first to minimize the chance of race condition
echo "Download snapshot (hashes) ..."
$CURL_WRAP -sSL -o snapshot.json.bak "$HACKAGE_BASE_URL/snapshot.json" &> /dev/null

echo "Download latest index ..."
$CURL_WRAP -sSL -o index.tar.gz "$HACKAGE_BASE_URL/01-index.tar.gz" &> /dev/null

echo "Download latest legacy (00-index) index ..."
$CURL_WRAP -sSL -o index-00.tar.gz "$HACKAGE_BASE_URL/00-index.tar.gz" &> /dev/null

# download extra json files
extra_json=("mirrors.json" "root.json" "snapshot.json" "timestamp.json")
extra_json=("mirrors.json" "root.json" "timestamp.json")
for json in "${extra_json[@]}"; do
$CURL_WRAP -sSL -o "$json" "$HACKAGE_BASE_URL/$json" &> /dev/null
done
Expand Down Expand Up @@ -79,6 +84,7 @@ function pull_hackage () {

cp index.tar.gz 01-index.tar.gz
mv index-00.tar.gz 00-index.tar.gz
mv snapshot.json.bak snapshot.json
}

function download_pkg () {
Expand Down

0 comments on commit cc6814f

Please sign in to comment.