mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-05 23:47:54 +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
|
return o
|
||||||
})()
|
})()
|
||||||
|
|
||||||
|
let throttleProgressTimer: number | null = null
|
||||||
checkAndDownloadPuppeteerExecutable({
|
checkAndDownloadPuppeteerExecutable({
|
||||||
downloadProgressCallback(downloadedBytes: number, totalBytes: number) {
|
downloadProgressCallback(downloadedBytes: number, totalBytes: number) {
|
||||||
clearTimeout(timeoutTimer)
|
clearTimeout(timeoutTimer)
|
||||||
@@ -47,16 +48,30 @@ export const checkAndDownloadDependenciesForInit = async () => {
|
|||||||
// will encounter this when network disconnected when downloading
|
// will encounter this when network disconnected when downloading
|
||||||
promiseWithResolver.reject(new Error('PROGRESS_NOT_CHANGED_TOO_LONG'))
|
promiseWithResolver.reject(new Error('PROGRESS_NOT_CHANGED_TOO_LONG'))
|
||||||
}, 5 * 1000)
|
}, 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(() => {
|
.then(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user