Skip to content

Commit

Permalink
hackage: Also sync timestamp before 01-index
Browse files Browse the repository at this point in the history
timestamp.json contains hash of snapshot.json.
Related: ustclug/discussions#482
  • Loading branch information
taoky committed Dec 28, 2024
1 parent 78ab293 commit 1da5998
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions hackage/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ function pull_hackage () {
# 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
snapshot_json=("snapshot.json" "timestamp.json")
for json in "${snapshot_json[@]}"; do
$CURL_WRAP -sSL -o "$json.bak" "$HACKAGE_BASE_URL/$json" &> /dev/null
done

echo "Download latest index ..."
$CURL_WRAP -sSL -o index.tar.gz "$HACKAGE_BASE_URL/01-index.tar.gz" &> /dev/null
Expand All @@ -30,7 +33,7 @@ function pull_hackage () {
$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" "timestamp.json")
extra_json=("mirrors.json" "root.json")
for json in "${extra_json[@]}"; do
$CURL_WRAP -sSL -o "$json" "$HACKAGE_BASE_URL/$json" &> /dev/null
done
Expand Down Expand Up @@ -85,6 +88,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
mv timestamp.json.bak timestamp.json
}

function download_pkg () {
Expand Down

0 comments on commit 1da5998

Please sign in to comment.