mirror of https://github.com/actions/toolkit
Fix bugs
parent
3d0da1ea1a
commit
ae026cf7c6
|
@ -10,7 +10,7 @@ import * as util from 'util'
|
||||||
import * as utils from './cacheUtils'
|
import * as utils from './cacheUtils'
|
||||||
import {SocketTimeout} from './constants'
|
import {SocketTimeout} from './constants'
|
||||||
import {DownloadOptions} from '../options'
|
import {DownloadOptions} from '../options'
|
||||||
import {retryHttpClientResponse} from './requestUtils'
|
import {retryHttpClientResponse, sleep} from './requestUtils'
|
||||||
|
|
||||||
import {AbortController} from '@azure/abort-controller'
|
import {AbortController} from '@azure/abort-controller'
|
||||||
|
|
||||||
|
@ -162,22 +162,23 @@ export class DownloadProgress {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function displayDownloadProgress(socket: any, startTime: number): Promise<void> {
|
async function displayDownloadProgress(socket: any, startTime: number): Promise<void> {
|
||||||
while(!socket.complete) {
|
while(!socket.destroyed) {
|
||||||
const transferredBytes = socket.bytesRead
|
const byteRead = socket.bytesRead
|
||||||
const totalBytes = 100000
|
const totalBytes = 100000
|
||||||
const percentage = (100 * (transferredBytes / totalBytes)).toFixed(
|
const percentage = (100 * (byteRead / totalBytes)).toFixed(
|
||||||
1
|
1
|
||||||
)
|
)
|
||||||
const elapsedTime = Date.now() - startTime
|
const elapsedTime = Date.now() - startTime
|
||||||
const downloadSpeed = (
|
const downloadSpeed = (
|
||||||
transferredBytes /
|
byteRead /
|
||||||
(1024 * 1024) /
|
(1024 * 1024) /
|
||||||
(elapsedTime / 1000)
|
(elapsedTime / 1000)
|
||||||
).toFixed(1)
|
).toFixed(1)
|
||||||
|
|
||||||
core.info(
|
core.info(
|
||||||
`Received ${transferredBytes} of ${totalBytes} (${percentage}%), ${downloadSpeed} MBs/sec`
|
`Received ${byteRead} of ${totalBytes} (${percentage}%), ${downloadSpeed} MBs/sec`
|
||||||
)
|
)
|
||||||
|
sleep(10)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ export function isRetryableStatusCode(statusCode?: number): boolean {
|
||||||
return retryableStatusCodes.includes(statusCode)
|
return retryableStatusCodes.includes(statusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sleep(milliseconds: number): Promise<void> {
|
export async function sleep(milliseconds: number): Promise<void> {
|
||||||
return new Promise(resolve => setTimeout(resolve, milliseconds))
|
return new Promise(resolve => setTimeout(resolve, milliseconds))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue