7415: Code: reduce progress notification spam r=lnicola a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
This commit is contained in:
bors[bot] 2021-01-25 08:34:36 +00:00 committed by GitHub
commit 911ff38eae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -99,13 +99,15 @@ export async function download(opts: DownloadOpts) {
async (progress, _cancellationToken) => {
let lastPercentage = 0;
await downloadFile(opts.url, tempFile, opts.mode, !!opts.gunzip, (readBytes, totalBytes) => {
const newPercentage = (readBytes / totalBytes) * 100;
progress.report({
message: newPercentage.toFixed(0) + "%",
increment: newPercentage - lastPercentage
});
const newPercentage = Math.round((readBytes / totalBytes) * 100);
if (newPercentage !== lastPercentage) {
progress.report({
message: `${newPercentage.toFixed(0)}%`,
increment: newPercentage - lastPercentage
});
lastPercentage = newPercentage;
lastPercentage = newPercentage;
}
});
}
);