diff options
author | 0neGal <mail@0negal.com> | 2022-06-29 21:55:22 +0200 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2022-06-29 21:55:22 +0200 |
commit | 7cc1e0aa6f796a07b8e97fab06e1bf6800a8e144 (patch) | |
tree | 0908ebf8af5f2979714ed0f19206768074a19b57 | |
parent | 3c09709b8f7cfb85b82d3d53feb81a74a5103135 (diff) | |
download | Viper-7cc1e0aa6f796a07b8e97fab06e1bf6800a8e144.tar.gz Viper-7cc1e0aa6f796a07b8e97fab06e1bf6800a8e144.zip |
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.
-rw-r--r-- | src/utils.js | 17 |
1 files changed, 15 insertions, 2 deletions
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(); |