Skip to content

Commit

Permalink
move dolphin back to AppData on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
JLaferri committed Mar 12, 2019
1 parent 2820e53 commit 4477c01
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
22 changes: 22 additions & 0 deletions app/main.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions app/utils/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
"win": {
"target": [
"nsis"
]
],
"requestedExecutionLevel": "highestAvailable"
},
"nsis": {
"perMachine": true,
Expand Down

0 comments on commit 4477c01

Please sign in to comment.