mirror of https://github.com/keeweb/keeweb.git
fix #1806: fixed a possible config loading error during startup
This commit is contained in:
parent
535cdc72f7
commit
70b4effde8
|
@ -97,7 +97,11 @@ const settingsPromise = loadSettingsEncryptionKey().then((key) => {
|
||||||
logProgress('loading settings key');
|
logProgress('loading settings key');
|
||||||
|
|
||||||
return loadConfig('app-settings').then((settings) => {
|
return loadConfig('app-settings').then((settings) => {
|
||||||
|
try {
|
||||||
appSettings = settings ? JSON.parse(settings) : {};
|
appSettings = settings ? JSON.parse(settings) : {};
|
||||||
|
} catch (e) {
|
||||||
|
logStartupMessage(`Error loading app settings: ${e}`);
|
||||||
|
}
|
||||||
logProgress('reading app settings');
|
logProgress('reading app settings');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -444,7 +448,11 @@ function restoreMainWindowPosition() {
|
||||||
const fileName = path.join(main.getPath('userData'), windowPositionFileName);
|
const fileName = path.join(main.getPath('userData'), windowPositionFileName);
|
||||||
fs.readFile(fileName, 'utf8', (e, data) => {
|
fs.readFile(fileName, 'utf8', (e, data) => {
|
||||||
if (data) {
|
if (data) {
|
||||||
|
try {
|
||||||
mainWindowPosition = JSON.parse(data);
|
mainWindowPosition = JSON.parse(data);
|
||||||
|
} catch (e) {
|
||||||
|
logStartupMessage(`Error loading main window position: ${e}`);
|
||||||
|
}
|
||||||
if (mainWindow && mainWindowPosition) {
|
if (mainWindow && mainWindowPosition) {
|
||||||
if (mainWindowPosition.width && mainWindowPosition.height) {
|
if (mainWindowPosition.width && mainWindowPosition.height) {
|
||||||
mainWindow.setBounds(mainWindowPosition);
|
mainWindow.setBounds(mainWindowPosition);
|
||||||
|
@ -650,7 +658,9 @@ function setUserDataPaths() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDev && process.env.KEEWEB_IS_PORTABLE) {
|
if (isDev && process.env.KEEWEB_IS_PORTABLE) {
|
||||||
|
try {
|
||||||
isPortable = !!JSON.parse(process.env.KEEWEB_IS_PORTABLE);
|
isPortable = !!JSON.parse(process.env.KEEWEB_IS_PORTABLE);
|
||||||
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
logProgress('portable check');
|
logProgress('portable check');
|
||||||
|
@ -660,8 +670,12 @@ function setUserDataPaths() {
|
||||||
const portableConfigPath = path.join(portableConfigDir, portableConfigFileName);
|
const portableConfigPath = path.join(portableConfigDir, portableConfigFileName);
|
||||||
|
|
||||||
if (fs.existsSync(portableConfigPath)) {
|
if (fs.existsSync(portableConfigPath)) {
|
||||||
|
try {
|
||||||
const portableConfig = JSON.parse(fs.readFileSync(portableConfigPath, 'utf8'));
|
const portableConfig = JSON.parse(fs.readFileSync(portableConfigPath, 'utf8'));
|
||||||
const portableUserDataDir = path.resolve(portableConfigDir, portableConfig.userDataDir);
|
const portableUserDataDir = path.resolve(
|
||||||
|
portableConfigDir,
|
||||||
|
portableConfig.userDataDir
|
||||||
|
);
|
||||||
|
|
||||||
if (!fs.existsSync(portableUserDataDir)) {
|
if (!fs.existsSync(portableUserDataDir)) {
|
||||||
fs.mkdirSync(portableUserDataDir, { recursive: true });
|
fs.mkdirSync(portableUserDataDir, { recursive: true });
|
||||||
|
@ -669,6 +683,9 @@ function setUserDataPaths() {
|
||||||
|
|
||||||
main.setPath('userData', portableUserDataDir);
|
main.setPath('userData', portableUserDataDir);
|
||||||
usingPortableUserDataDir = true;
|
usingPortableUserDataDir = true;
|
||||||
|
} catch (e) {
|
||||||
|
logStartupMessage(`Error loading portable config: ${e}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -914,7 +931,9 @@ function loadLocale() {
|
||||||
if (appSettings?.locale === localeValues?.locale) {
|
if (appSettings?.locale === localeValues?.locale) {
|
||||||
setLocale(localeValues);
|
setLocale(localeValues);
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch (e) {
|
||||||
|
logStartupMessage(`Error loading locale: ${e}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
locale.on('changed', () => {
|
locale.on('changed', () => {
|
||||||
setMenu();
|
setMenu();
|
||||||
|
|
|
@ -3,6 +3,7 @@ Release notes
|
||||||
##### v1.18.3 (2021-05-09)
|
##### v1.18.3 (2021-05-09)
|
||||||
`-` fix #1804: filling OTP in browser extensions
|
`-` fix #1804: filling OTP in browser extensions
|
||||||
`*` fix #1805: auto-unchecking auto-type filters if nothing found
|
`*` fix #1805: auto-unchecking auto-type filters if nothing found
|
||||||
|
`*` fix #1806: fixed a possible config loading error during startup
|
||||||
|
|
||||||
##### v1.18.2 (2021-05-08)
|
##### v1.18.2 (2021-05-08)
|
||||||
`-` fix #1802: opening files with saved keyfiles
|
`-` fix #1802: opening files with saved keyfiles
|
||||||
|
|
Loading…
Reference in New Issue