mirror of
https://github.com/gradle/actions.git
synced 2025-04-20 09:49:19 +08:00
Fetch checksum values in batches
This commit is contained in:
parent
e0475e1bea
commit
1a1961913d
@ -1,5 +1,6 @@
|
||||
import * as httpm from 'typed-rest-client/HttpClient'
|
||||
import * as cheerio from 'cheerio'
|
||||
import * as core from '@actions/core'
|
||||
|
||||
import fileWrapperChecksums from './wrapper-checksums.json'
|
||||
|
||||
@ -59,12 +60,7 @@ export async function fetchUnknownChecksums(
|
||||
}
|
||||
|
||||
const wrapperChecksums = new WrapperChecksums()
|
||||
await Promise.all(
|
||||
checksumUrls.map(async ([version, url]) => {
|
||||
const checksum = await httpGetText(url)
|
||||
wrapperChecksums.add(version, checksum)
|
||||
})
|
||||
)
|
||||
await fetchAndStoreChecksums(checksumUrls, wrapperChecksums)
|
||||
return wrapperChecksums
|
||||
}
|
||||
|
||||
@ -94,3 +90,20 @@ async function addDistributionSnapshotChecksumUrls(checksumUrls: [string, string
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function fetchAndStoreChecksums(
|
||||
checksumUrls: [string, string][],
|
||||
wrapperChecksums: WrapperChecksums
|
||||
): Promise<void> {
|
||||
const batchSize = 10
|
||||
for (let i = 0; i < checksumUrls.length; i += batchSize) {
|
||||
const batch = checksumUrls.slice(i, i + batchSize)
|
||||
await Promise.all(
|
||||
batch.map(async ([version, url]) => {
|
||||
const checksum = await httpGetText(url)
|
||||
wrapperChecksums.add(version, checksum)
|
||||
})
|
||||
)
|
||||
core.info(`Fetched ${i + batch.length} of ${checksumUrls.length} checksums`)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user