diff options
author | Laurențiu Nicola <[email protected]> | 2021-01-24 14:13:33 +0000 |
---|---|---|
committer | Laurențiu Nicola <[email protected]> | 2021-01-25 08:05:38 +0000 |
commit | 5bd84716ed6efe41a183c4ae3db364e2c49fa9cb (patch) | |
tree | cf15a498d09dca9ec7d05c499bea67bf23e1c092 | |
parent | 3ab8d7a9ae1b8c5e421a4666f6693ae7278a7a3c (diff) |
Code: reduce progress notification spam
-rw-r--r-- | editors/code/src/net.ts | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/editors/code/src/net.ts b/editors/code/src/net.ts index 1ab21e726..3e50d352c 100644 --- a/editors/code/src/net.ts +++ b/editors/code/src/net.ts | |||
@@ -99,13 +99,15 @@ export async function download(opts: DownloadOpts) { | |||
99 | async (progress, _cancellationToken) => { | 99 | async (progress, _cancellationToken) => { |
100 | let lastPercentage = 0; | 100 | let lastPercentage = 0; |
101 | await downloadFile(opts.url, tempFile, opts.mode, !!opts.gunzip, (readBytes, totalBytes) => { | 101 | await downloadFile(opts.url, tempFile, opts.mode, !!opts.gunzip, (readBytes, totalBytes) => { |
102 | const newPercentage = (readBytes / totalBytes) * 100; | 102 | const newPercentage = Math.round((readBytes / totalBytes) * 100); |
103 | progress.report({ | 103 | if (newPercentage !== lastPercentage) { |
104 | message: newPercentage.toFixed(0) + "%", | 104 | progress.report({ |
105 | increment: newPercentage - lastPercentage | 105 | message: `${newPercentage.toFixed(0)}%`, |
106 | }); | 106 | increment: newPercentage - lastPercentage |
107 | 107 | }); | |
108 | lastPercentage = newPercentage; | 108 | |
109 | lastPercentage = newPercentage; | ||
110 | } | ||
109 | }); | 111 | }); |
110 | } | 112 | } |
111 | ); | 113 | ); |