From 587ad5703d91f2bcf003fbe90a0c8cdbcd082a39 Mon Sep 17 00:00:00 2001 From: MathieuG-P Date: Tue, 19 Jul 2022 20:56:54 +0200 Subject: [PATCH] add type and use bsmException --- src/main/services/installation-location.service.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/services/installation-location.service.ts b/src/main/services/installation-location.service.ts index 1fca3a74..14b76f8d 100644 --- a/src/main/services/installation-location.service.ts +++ b/src/main/services/installation-location.service.ts @@ -3,6 +3,8 @@ import { ConfigurationService } from "./configuration.service"; import { UtilsService } from "./utils.service"; import fs from 'fs-extra'; import log from "electron-log"; +import { app } from "electron/main"; +import { BsmException } from "shared/models/bsm-exception.model"; export class InstallationLocationService { @@ -31,7 +33,7 @@ export class InstallationLocationService { } private initInstallationLocation(): void{ - this._installationDirectory = (this.configService.get(this.STORE_INSTALLATION_PATH_KEY) || this.utilsService.getUserDocumentsFolder()) as string; + this._installationDirectory = this.configService.get(this.STORE_INSTALLATION_PATH_KEY) || app.getPath("documents"); } public get installationDirectory(): string{ return path.join(this._installationDirectory, this.INSTALLATION_FOLDER); } @@ -46,8 +48,8 @@ export class InstallationLocationService { this._installationDirectory = newDir; this.configService.store.set(this.STORE_INSTALLATION_PATH_KEY, newDir); resolve(this.installationDirectory); - }).catch(err => { - reject(err); + }).catch((err: Error) => { + reject({title: "CantMoveFolder", error: err} as BsmException); log.error(err); }) })