mirror of https://github.com/actions/toolkit
making a promise array
parent
c33724abbd
commit
b54065b5da
|
@ -39,19 +39,29 @@ async function exists(path: string): Promise<boolean> {
|
||||||
|
|
||||||
async function streamExtract(url: string, directory: string): Promise<void> {
|
async function streamExtract(url: string, directory: string): Promise<void> {
|
||||||
let retryCount = 0
|
let retryCount = 0
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const promises: Promise<any>[] = []
|
||||||
while (retryCount < 5) {
|
while (retryCount < 5) {
|
||||||
|
const promise = new Promise(async () => {
|
||||||
try {
|
try {
|
||||||
await streamExtractInternal(url, directory)
|
await streamExtractInternal(url, directory)
|
||||||
return
|
} catch (err) {
|
||||||
} catch (error) {
|
|
||||||
retryCount++
|
retryCount++
|
||||||
core.warning(`Failed to download artifact. Retrying in 5 seconds...`)
|
core.warning(`Failed to download artifact. Retrying in 5 seconds...`)
|
||||||
// wait 5 seconds before retrying
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 5000))
|
await new Promise(resolve => setTimeout(resolve, 5000))
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
promises.push(promise)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await Promise.all(promises)
|
||||||
|
core.info('All Promises Returned')
|
||||||
|
} catch (error) {
|
||||||
throw new Error(`Artifact download failed after ${retryCount} retries.`)
|
throw new Error(`Artifact download failed after ${retryCount} retries.`)
|
||||||
|
}
|
||||||
|
|
||||||
|
// throw new Error(`Artifact download failed after ${retryCount} retries.`)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function streamExtractInternal(
|
async function streamExtractInternal(
|
||||||
|
|
Loading…
Reference in New Issue