mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-05-02 18:28:04 +08:00
Await finish of filestream so file is created for node16
This commit is contained in:
@@ -219,6 +219,14 @@ export class DownloadHttpClient {
|
||||
fileDownloadPath: string
|
||||
): Promise<void> => {
|
||||
destinationStream.close()
|
||||
// await until file is created at downloadpath
|
||||
// wrap destinationStream's open event in promise
|
||||
await new Promise<void>(resolve => {
|
||||
destinationStream.on('close', resolve)
|
||||
if (destinationStream.writableFinished) {
|
||||
resolve()
|
||||
}
|
||||
});
|
||||
await rmFile(fileDownloadPath)
|
||||
destinationStream = fs.createWriteStream(fileDownloadPath)
|
||||
}
|
||||
@@ -273,8 +281,8 @@ export class DownloadHttpClient {
|
||||
// if a throttled status code is received, try to get the retryAfter header value, else differ to standard exponential backoff
|
||||
isThrottledStatusCode(response.message.statusCode)
|
||||
? await backOff(
|
||||
tryGetRetryAfterValueTimeInMilliseconds(response.message.headers)
|
||||
)
|
||||
tryGetRetryAfterValueTimeInMilliseconds(response.message.headers)
|
||||
)
|
||||
: await backOff()
|
||||
} else {
|
||||
// Some unexpected response code, fail immediately and stop the download
|
||||
|
||||
Reference in New Issue
Block a user