From 80f9c6fc687a68a24384c7290dc26041a5ffb478 Mon Sep 17 00:00:00 2001 From: Oj Date: Fri, 11 Feb 2022 08:52:00 +0000 Subject: [PATCH] [Updater > Request] Fix download progress --- src/updater/moduleUpdater.js | 6 +++--- src/updater/request.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/updater/moduleUpdater.js b/src/updater/moduleUpdater.js index d1522de..d482ceb 100644 --- a/src/updater/moduleUpdater.js +++ b/src/updater/moduleUpdater.js @@ -559,10 +559,10 @@ async function processDownloadQueue() { const stream = _fs.default.createWriteStream(moduleZipPath); - stream.on('progress', ({ - receivedBytes: newReceivedBytes, + stream.on('progress', ([ + newReceivedBytes, totalBytes - }) => { + ]) => { receivedBytes = newReceivedBytes; const newProgress = Math.min(Math.floor(100 * (receivedBytes / totalBytes)), 100); diff --git a/src/updater/request.js b/src/updater/request.js index e3794ce..7bdc36f 100644 --- a/src/updater/request.js +++ b/src/updater/request.js @@ -17,7 +17,7 @@ const nodeRequest = ({ method, url, headers, qs, timeout, body, stream }) => new if (!stream) return; outOf += chunk.length; stream.write(chunk); - stream.emit('progress', { total, outOf }); + stream.emit('progress', [ outOf, total ]); }); response.on('end', () => {