better portable app checks

This commit is contained in:
antelle 2020-05-22 10:56:08 +02:00
parent e9ef1bd698
commit c3b55cd7fa
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
1 changed files with 12 additions and 3 deletions

View File

@ -29,6 +29,10 @@ if (!gotTheLock) {
perfTimestamps?.push({ name: 'single instance lock', ts: process.hrtime() });
let isPortable;
let execPath;
setPortableAndExecPath();
initUserDataDir();
let openFile = process.argv.filter(arg => /\.kdbx$/i.test(arg))[0];
@ -161,6 +165,7 @@ app.reqNative = function(mod) {
return binding;
};
app.showAndFocusMainWindow = showAndFocusMainWindow;
app.isPortable = isPortable;
function readAppSettings() {
const appSettingsFilePath = path.join(app.getPath('userData'), appSettingsFileName);
@ -510,9 +515,9 @@ function subscribePowerEvents() {
perfTimestamps?.push({ name: 'subscribing to power events', ts: process.hrtime() });
}
function initUserDataDir() {
let execPath = process.execPath;
let isPortable;
function setPortableAndExecPath() {
execPath = process.execPath;
switch (process.platform) {
case 'darwin':
isPortable = !execPath.startsWith('/Applications/');
@ -528,6 +533,10 @@ function initUserDataDir() {
break;
}
perfTimestamps?.push({ name: 'portable check', ts: process.hrtime() });
}
function initUserDataDir() {
if (isPortable) {
const portableConfigDir = path.dirname(execPath);
const portableConfigPath = path.join(portableConfigDir, portableConfigFileName);