From 4477c01323d00afd3d7a0ccad7bbd3f26a12e789 Mon Sep 17 00:00:00 2001 From: Jas Laferriere Date: Mon, 11 Mar 2019 17:26:32 -0700 Subject: [PATCH] move dolphin back to AppData on Windows --- app/main.dev.js | 22 ++++++++++++++++++++++ app/utils/settings.js | 7 +++++++ package.json | 3 ++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/app/main.dev.js b/app/main.dev.js index d87b78d9b..6514b6534 100644 --- a/app/main.dev.js +++ b/app/main.dev.js @@ -17,6 +17,7 @@ import { URL } from 'url'; import { autoUpdater } from 'electron-updater'; import log from 'electron-log'; import path from 'path'; +import fs from 'fs-extra'; import MenuBuilder from './menu'; // Set up AppUpdater @@ -43,6 +44,27 @@ if ( require('electron-debug')(); } +const platform = process.platform; +if (process.env.NODE_ENV === 'production' && platform === "win32") { + log.info("Checking if Dolphin path has been moved..."); + + // If on production and windows, check if dolphin has been moved to the right place + const appPath = app.getAppPath(); + const originalDolphinPath = path.join(appPath, "../app.asar.unpacked/app/dolphin"); + log.info(`Looking for ${originalDolphinPath}`); + const originalPathExists = fs.existsSync(originalDolphinPath); + + if (originalPathExists) { + // If path exists, let's move it to app data + log.info("Moving dolphin path..."); + const userDataPath = app.getPath("userData") + const targetPath = path.join(userDataPath, 'dolphin'); + fs.moveSync(originalDolphinPath, targetPath, true); + } else { + log.info("Path not found, we're good?"); + } +} + const installExtensions = async () => { const installer = require('electron-devtools-installer'); const forceDownload = !!process.env.UPGRADE_EXTENSIONS; diff --git a/app/utils/settings.js b/app/utils/settings.js index b919b0be4..3b006b67e 100644 --- a/app/utils/settings.js +++ b/app/utils/settings.js @@ -19,6 +19,13 @@ export function getDolphinPath() { export function getDefaultDolphinPath() { // Build default packaged path + const platform = process.platform; + if (platform === "win32") { + // In windows we move dolphin to AppData so settings will save + const userDataPath = app.getPath("userData") + return path.join(userDataPath, 'dolphin'); + } + const appPath = app.getAppPath(); return path.join(appPath, "../app.asar.unpacked/app/dolphin"); } diff --git a/package.json b/package.json index 7f303a9bf..904974272 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,8 @@ "win": { "target": [ "nsis" - ] + ], + "requestedExecutionLevel": "highestAvailable" }, "nsis": { "perMachine": true,