Skip to content

Commit 1da5998

Browse files
committed
hackage: Also sync timestamp before 01-index
timestamp.json contains hash of snapshot.json. Related: ustclug/discussions#482
1 parent 78ab293 commit 1da5998

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

hackage/sync.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ function pull_hackage () {
2121
# snapshot.json contains hashes of 01-index.tar.gz
2222
# Download it first to minimize the chance of race condition
2323
echo "Download snapshot (hashes) ..."
24-
$CURL_WRAP -sSL -o snapshot.json.bak "$HACKAGE_BASE_URL/snapshot.json" &> /dev/null
24+
snapshot_json=("snapshot.json" "timestamp.json")
25+
for json in "${snapshot_json[@]}"; do
26+
$CURL_WRAP -sSL -o "$json.bak" "$HACKAGE_BASE_URL/$json" &> /dev/null
27+
done
2528

2629
echo "Download latest index ..."
2730
$CURL_WRAP -sSL -o index.tar.gz "$HACKAGE_BASE_URL/01-index.tar.gz" &> /dev/null
@@ -30,7 +33,7 @@ function pull_hackage () {
3033
$CURL_WRAP -sSL -o index-00.tar.gz "$HACKAGE_BASE_URL/00-index.tar.gz" &> /dev/null
3134

3235
# download extra json files
33-
extra_json=("mirrors.json" "root.json" "timestamp.json")
36+
extra_json=("mirrors.json" "root.json")
3437
for json in "${extra_json[@]}"; do
3538
$CURL_WRAP -sSL -o "$json" "$HACKAGE_BASE_URL/$json" &> /dev/null
3639
done
@@ -85,6 +88,7 @@ function pull_hackage () {
8588
cp index.tar.gz 01-index.tar.gz
8689
mv index-00.tar.gz 00-index.tar.gz
8790
mv snapshot.json.bak snapshot.json
91+
mv timestamp.json.bak timestamp.json
8892
}
8993

9094
function download_pkg () {

0 commit comments

Comments
 (0)