From 7cc1e0aa6f796a07b8e97fab06e1bf6800a8e144 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Wed, 29 Jun 2022 21:55:22 +0200 Subject: added extract progress messages When progress is made on extracting the Northstar zip file it'll update the "Extracting..." message to "Extracting... X%" replacing X with the amount that's been extracted. --- src/utils.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/utils.js b/src/utils.js index e0f3a6f..e8d14cc 100644 --- a/src/utils.js +++ b/src/utils.js @@ -401,13 +401,26 @@ async function update() { stream.on("finish", () => { stream.close(); + let extract = fs.createReadStream(settings.zip); + winLog(lang("gui.update.extracting")); ipcMain.emit("ns-update-event", "gui.update.extracting"); console.log(lang("cli.update.downloaddone")); // Extracts the zip, this is the part where we're actually // installing Northstar. - fs.createReadStream(settings.zip).pipe(unzip.Extract({path: settings.gamepath})) - .on("finish", () => { + extract.pipe(unzip.Extract({path: settings.gamepath})) + + let max = received; + received = 0; + + extract.on("data", (chunk) => { + received += chunk.length; + let percent = Math.floor(received / max * 100); + ipcMain.emit("ns-update-event", lang("gui.update.extracting") + " " + percent + "%"); + }) + + extract.on("end", () => { + extract.close(); ipcMain.emit("getversion"); restoreExcludedFiles(); -- cgit v1.2.3