mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-05-15 20:39:02 +08:00
remove console, and decrease the pipe write times for downloadProgressCallback, to solve the download process is badly block at a point on windows
This commit is contained in:
@@ -39,6 +39,7 @@ export const checkAndDownloadDependenciesForInit = async () => {
|
||||
return o
|
||||
})()
|
||||
|
||||
let throttleProgressTimer: number | null = null
|
||||
checkAndDownloadPuppeteerExecutable({
|
||||
downloadProgressCallback(downloadedBytes: number, totalBytes: number) {
|
||||
clearTimeout(timeoutTimer)
|
||||
@@ -47,16 +48,30 @@ export const checkAndDownloadDependenciesForInit = async () => {
|
||||
// will encounter this when network disconnected when downloading
|
||||
promiseWithResolver.reject(new Error('PROGRESS_NOT_CHANGED_TOO_LONG'))
|
||||
}, 5 * 1000)
|
||||
} else {
|
||||
clearTimeout(throttleProgressTimer)
|
||||
throttleProgressTimer = null
|
||||
}
|
||||
|
||||
if (!throttleProgressTimer) {
|
||||
// console.log(JSON.stringify({
|
||||
// type: 'DOWNLOAD_PROGRESS_UPDATE',
|
||||
// level: 'DEBUG',
|
||||
// percent: downloadedBytes / totalBytes
|
||||
// }))
|
||||
|
||||
pipeWriteRegardlessError(
|
||||
pipe,
|
||||
JSON.stringify({
|
||||
type: 'PUPPETEER_DOWNLOAD_PROGRESS',
|
||||
totalBytes,
|
||||
downloadedBytes
|
||||
}) + '\r\n'
|
||||
)
|
||||
throttleProgressTimer = setTimeout(() => {
|
||||
throttleProgressTimer = null
|
||||
}, 2500)
|
||||
}
|
||||
console.log(downloadedBytes / totalBytes)
|
||||
pipeWriteRegardlessError(
|
||||
pipe,
|
||||
JSON.stringify({
|
||||
type: 'PUPPETEER_DOWNLOAD_PROGRESS',
|
||||
totalBytes,
|
||||
downloadedBytes
|
||||
})
|
||||
) + '\r\n'
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
|
||||
Reference in New Issue
Block a user