loading progress NaN fix

This commit is contained in:
Drew Ansbacher
2021-12-01 17:18:48 -07:00
committed by Aiden McClelland
parent d38da2231e
commit c9d77e99af
10 changed files with 34 additions and 46 deletions

View File

@@ -28,17 +28,19 @@ export function packageLoadingProgress (
unpackWeight * unpacked,
)
const denominator = Math.floor(
size * (downloadWeight + validateWeight + unpackWeight),
)
const totalProgress = Math.floor(100 * numerator / denominator)
return {
totalProgress,
downloadProgress: Math.floor((100 * downloaded) / size),
validateProgress: Math.floor((100 * validated) / size),
unpackProgress: Math.floor((100 * unpacked) / size),
isComplete: downloadComplete && validationComplete && unpackComplete,
display: totalProgress > 98 ? 'Finalizing' : `${totalProgress}%`,
display: totalProgress > 98 ? 'Finalizing...' : `Installing... ${totalProgress}%`,
}
}