diff --git a/src/main/ipcs/bs-version-ipcs.ts b/src/main/ipcs/bs-version-ipcs.ts index 6f772bda..d7898422 100644 --- a/src/main/ipcs/bs-version-ipcs.ts +++ b/src/main/ipcs/bs-version-ipcs.ts @@ -30,7 +30,7 @@ ipcMain.on('bs-version.installed-versions', async (event, req: IpcRequest) ipcMain.on("bs-version.open-folder", async (event, req: IpcRequest) => { const localVersionService = BSLocalVersionService.getInstance(); const versionFolder = await localVersionService.getVersionPath(req.args); - UtilsService.getInstance().folderExist(versionFolder) && exec(`start "" "${versionFolder}"`); + UtilsService.getInstance().pathExist(versionFolder) && exec(`start "" "${versionFolder}"`); }); ipcMain.on("bs-version.edit", async (event, req: IpcRequest<{version: BSVersion, name: string, color: string}>) => { diff --git a/src/main/main.ts b/src/main/main.ts index 82db8b6b..7c93dd4f 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -88,8 +88,6 @@ const createWindow = async () => { UtilsService.getInstance().setMainWindow(mainWindow); - - mainWindow.loadURL(resolveHtmlPath('index.html')); mainWindow.on('ready-to-show', () => { diff --git a/src/main/services/bs-local-version.service.ts b/src/main/services/bs-local-version.service.ts index be918972..697e3078 100644 --- a/src/main/services/bs-local-version.service.ts +++ b/src/main/services/bs-local-version.service.ts @@ -121,7 +121,7 @@ export class BSLocalVersionService{ public async deleteVersion(version: BSVersion): Promise{ if(version.steam){ return false; } const versionFolder = await this.getVersionPath(version); - if(!this.utilsService.folderExist(versionFolder)){ return true; } + if(!this.utilsService.pathExist(versionFolder)){ return true; } return this.utilsService.deleteFolder(versionFolder) .then(() => { return true; }) diff --git a/src/main/services/utils.service.ts b/src/main/services/utils.service.ts index 801a4bad..4d3cebdd 100644 --- a/src/main/services/utils.service.ts +++ b/src/main/services/utils.service.ts @@ -5,6 +5,7 @@ import path from "path"; import { BrowserWindow } from "electron"; import { rm } from "fs/promises"; import { IpcResponse } from "shared/models/ipc"; +import log from "electron-log"; export class UtilsService{ @@ -29,13 +30,10 @@ export class UtilsService{ public setMainWindow(win: BrowserWindow){ this.mainWindow = win; } - //à supprimer - public folderExist(path: string): boolean{ return existsSync(path); } - public pathExist(path: string): boolean{ return existsSync(path); } public createFolderIfNotExist(path: string): void{ - if(!this.folderExist(path)){ mkdirSync(path, {recursive: true}); } + if(!this.pathExist(path)){ mkdirSync(path, {recursive: true}); } } public taskRunning(task: string): boolean{ @@ -69,7 +67,11 @@ export class UtilsService{ } public ipcSend(channel: string, response: IpcResponse): void{ - this.mainWindow.webContents.send(channel, response); + try { + this.mainWindow.webContents.send(channel, response); + } catch (error) { + log.error(error); + } } }