Merge #7415
7415: Code: reduce progress notification spam r=lnicola a=lnicola Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
This commit is contained in:
commit
911ff38eae
1 changed files with 8 additions and 6 deletions
|
@ -99,13 +99,15 @@ export async function download(opts: DownloadOpts) {
|
||||||
async (progress, _cancellationToken) => {
|
async (progress, _cancellationToken) => {
|
||||||
let lastPercentage = 0;
|
let lastPercentage = 0;
|
||||||
await downloadFile(opts.url, tempFile, opts.mode, !!opts.gunzip, (readBytes, totalBytes) => {
|
await downloadFile(opts.url, tempFile, opts.mode, !!opts.gunzip, (readBytes, totalBytes) => {
|
||||||
const newPercentage = (readBytes / totalBytes) * 100;
|
const newPercentage = Math.round((readBytes / totalBytes) * 100);
|
||||||
progress.report({
|
if (newPercentage !== lastPercentage) {
|
||||||
message: newPercentage.toFixed(0) + "%",
|
progress.report({
|
||||||
increment: newPercentage - lastPercentage
|
message: `${newPercentage.toFixed(0)}%`,
|
||||||
});
|
increment: newPercentage - lastPercentage
|
||||||
|
});
|
||||||
|
|
||||||
lastPercentage = newPercentage;
|
lastPercentage = newPercentage;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue