Skip to content

Commit

Permalink
fix: create folders needed (#50)
Browse files Browse the repository at this point in the history
* fix: create folders needed

* check to remove folder

* chore: udpate version
  • Loading branch information
kuruk-mm authored Apr 14, 2022
1 parent 83a045e commit bd7df88
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
22 changes: 18 additions & 4 deletions electron/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ const reportFatalError = async (sender: WebContents, message: string) => {
}

const reportCrash = async (sender: WebContents) => {

const path = JSON.stringify({ playerlogpath: getPlayerLogPath() })
const data = JSON.stringify(`Player log:\n${getPlayerLog()}`)
const code = `window.Rollbar.error(${data}, ${path})`
Expand Down Expand Up @@ -159,7 +158,10 @@ const registerDownloadEvent = (win: BrowserWindow, launcherPaths: LauncherPaths)
//electronDl();
ipcMain.on('download', async (event) => {
const branchPath = launcherPaths.rendererPath + getBranchName()
fs.rmdirSync(branchPath, { recursive: true })
if (fs.existsSync(branchPath)) {
fs.rmSync(branchPath, { recursive: true })
}
createDirIfNotExists(branchPath)
const url = launcherPaths.baseUrl + main.config.desktopBranch + launcherPaths.artifactUrl
console.log('artifactUrl: ', url)
const res = await electronDl.download(win, url, {
Expand All @@ -175,7 +177,9 @@ const registerDownloadEvent = (win: BrowserWindow, launcherPaths: LauncherPaths)
onCompleted: (file) => {
console.log('onCompleted:', file)
unzip(file.path, branchPath, () => {
fs.rmSync(file.path)
if (fs.existsSync(file.path)) {
fs.rmSync(file.path)
}

const versionData = {
version: remoteVersion
Expand All @@ -193,8 +197,16 @@ const registerDownloadEvent = (win: BrowserWindow, launcherPaths: LauncherPaths)
})
}

const createDirIfNotExists = (path: string) => {
if (!fs.existsSync(path)) {
fs.mkdirSync(path)
}
}

export const registerUpdaterEvents = (win: BrowserWindow, launcherPaths: LauncherPaths) => {
try {
createDirIfNotExists(launcherPaths.rendererPath)

// Get version
registerVersionEvent(launcherPaths)

Expand All @@ -206,7 +218,9 @@ export const registerUpdaterEvents = (win: BrowserWindow, launcherPaths: Launche

// Register clear cache
ipcMain.on('clearCache', async (event) => {
fs.rmdirSync(launcherPaths.rendererPath, { recursive: true })
if (fs.existsSync(launcherPaths.rendererPath)) {
fs.rmSync(launcherPaths.rendererPath, { recursive: true })
}
})
} catch (e) {
console.error('registerUpdaterEvents error: ', e)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "explorer-desktop-launcher",
"version": "0.1.33",
"version": "0.1.34",
"author": "decentraland",
"description": "Decentraland Desktop Launcher",
"homepage": ".",
Expand Down

0 comments on commit bd7df88

Please sign in to comment.