diff options
Diffstat (limited to 'src/main/manaplus/manaApp/windows.ts')
-rw-r--r-- | src/main/manaplus/manaApp/windows.ts | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/main/manaplus/manaApp/windows.ts b/src/main/manaplus/manaApp/windows.ts index 7bf5adb..a8a0ebd 100644 --- a/src/main/manaplus/manaApp/windows.ts +++ b/src/main/manaplus/manaApp/windows.ts @@ -1,5 +1,4 @@ import { ManaPlusApp } from "./manaApp.interface"; -import { app } from "electron"; import * as fs from "fs-extra"; import { Status } from "../../status"; import { download, Progress as ProgressType } from "../../util/downloader"; @@ -9,16 +8,21 @@ import { getVersionInfoForPlatform, updateAvailable, } from "./shared"; +import { + getTempPath, + getManaPlusPath, + getUserDataPath, +} from "../../util/app_constants"; +import { join } from "path"; export class ManaPlusAppWindows implements ManaPlusApp { private path: string; public readonly startCommand: string; versionRegEx: RegExp = /.*ManaPlus ([\d.]+) Windows.*/g; constructor() { - const ManaPath = app.getPath("userData") + "\\manaplus"; + const ManaPath = getManaPlusPath(); fs.existsSync(ManaPath) || fs.mkdirSync(ManaPath); - fs.existsSync(app.getPath("userData") + "\\temp") || - fs.mkdirSync(app.getPath("userData") + "\\temp"); + fs.existsSync(getTempPath()) || fs.mkdirSync(getTempPath()); this.path = ManaPath; this.startCommand = this.path + "\\Mana\\manaplus.exe"; } @@ -34,8 +38,7 @@ export class ManaPlusAppWindows implements ManaPlusApp { } async update() { - fs.existsSync(app.getPath("userData") + "\\temp") || - fs.mkdirSync(app.getPath("userData") + "\\temp"); + fs.existsSync(getTempPath()) || fs.mkdirSync(getTempPath()); // Get Update URL Status.setProgress(500); Status.setActivity("Fetching Download URL"); @@ -48,9 +51,10 @@ export class ManaPlusAppWindows implements ManaPlusApp { } Status.setProgress(-1); - const updateDestination: string = `${app.getPath( - "userData" - )}\\temp\\update.zip`; + const updateDestination: string = join( + getUserDataPath(), + "\\temp\\update.zip" + ); try { await download(downloadURL, updateDestination, (state: ProgressType) => { Status.setProgress(Math.floor(state.percent * 100)); |