1
0
mirror of https://github.com/keeweb/keeweb.git synced 2024-06-20 06:56:40 +02:00

fixed some portable installation issues on macos

This commit is contained in:
antelle 2020-06-02 10:47:20 +02:00
parent a83e04fe4d
commit 435eb5779f
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C

View File

@ -30,11 +30,10 @@ if (!gotTheLock) {
perfTimestamps?.push({ name: 'single instance lock', ts: process.hrtime() });
let isPortable;
let usingPortableUserDataDir = false;
let execPath;
setPortableAndExecPath();
initUserDataDir();
setUserDataPaths();
let openFile = process.argv.filter((arg) => /\.kdbx$/i.test(arg))[0];
@ -542,12 +541,14 @@ function subscribePowerEvents() {
perfTimestamps?.push({ name: 'subscribing to power events', ts: process.hrtime() });
}
function setPortableAndExecPath() {
function setUserDataPaths() {
execPath = process.execPath;
let isPortable = false;
switch (process.platform) {
case 'darwin':
isPortable = !execPath.startsWith('/Applications/');
isPortable = !execPath.includes('/Applications/');
if (isPortable) {
execPath = execPath.substring(0, execPath.indexOf('.app'));
}
@ -565,9 +566,7 @@ function setPortableAndExecPath() {
}
perfTimestamps?.push({ name: 'portable check', ts: process.hrtime() });
}
function initUserDataDir() {
if (isPortable) {
const portableConfigDir = path.dirname(execPath);
const portableConfigPath = path.join(portableConfigDir, portableConfigFileName);
@ -581,6 +580,7 @@ function initUserDataDir() {
}
app.setPath('userData', portableUserDataDir);
usingPortableUserDataDir = true;
}
}
@ -771,7 +771,7 @@ function initUsb(binding) {
function loadSettingsEncryptionKey() {
return Promise.resolve().then(() => {
if (isPortable) {
if (usingPortableUserDataDir) {
return null;
}