Skip to content

Commit

Permalink
Fixed another bug lol
Browse files Browse the repository at this point in the history
  • Loading branch information
Ipmake committed Apr 11, 2023
1 parent e870ec4 commit 72b9e05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "knockoutcitylauncher",
"description": "Unofficial Knockout City Launcher",
"version": "0.1.2",
"version": "0.1.3",
"private": true,
"homepage": "./",
"main": "public/electron.js",
Expand Down
7 changes: 5 additions & 2 deletions public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ function createWindow () {
console.log("Downloaded");
// unzip the file
try {
win.setProgressBar(5)
if(fs.existsSync(`${arg.path}/${arg.version == 1 ? 'highRes' : 'lowRes'}`)) fs.rmdirSync(`${arg.path}/${arg.version == 1 ? 'highRes' : 'lowRes'}`, { recursive: true })
fs.mkdirSync(`${arg.path}/${arg.version == 1 ? 'highRes' : 'lowRes'}`)

Expand All @@ -106,9 +107,11 @@ function createWindow () {
console.log("Files unzipped successfully");
fs.rmSync(`${arg.path}/files-${arg.version}.zip`)
win.reload()
win.setProgressBar(-1)
});
} catch (err) {
console.log(err)
win.setProgressBar(-1)
dialog.showMessageBox(win, {
type: "error",
title: "Unexpected Error",
Expand All @@ -118,8 +121,8 @@ function createWindow () {
});

res.on('data', (chunk) => {
win.webContents.executeJavaScript(`window.postMessage({type: "download-progress", data: ${roundToDecimalPlace(((fileSize + writeStream.bytesWritten) / res.headers['content-length'] + fileSize) * 100, 2)}})`)
win.setProgressBar((fileSize + writeStream.bytesWritten) / res.headers['content-length'] + fileSize)
win.webContents.executeJavaScript(`window.postMessage({type: "download-progress", data: ${roundToDecimalPlace(((fileSize + writeStream.bytesWritten) / (res.headers['content-length'] + fileSize)) * 100, 2)}})`)
win.setProgressBar((fileSize + writeStream.bytesWritten) / (res.headers['content-length'] + fileSize))
});

ipcMain.once('cancel-download', async (event, arg) => {
Expand Down

0 comments on commit 72b9e05

Please sign in to comment.