aboutsummaryrefslogtreecommitdiffstats
path: root/packages/main/src/controllers/initConfig.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/main/src/controllers/initConfig.ts')
-rw-r--r--packages/main/src/controllers/initConfig.ts12
1 files changed, 7 insertions, 5 deletions
diff --git a/packages/main/src/controllers/initConfig.ts b/packages/main/src/controllers/initConfig.ts
index 915f451..93be978 100644
--- a/packages/main/src/controllers/initConfig.ts
+++ b/packages/main/src/controllers/initConfig.ts
@@ -19,11 +19,11 @@
19 */ 19 */
20 20
21import { debounce } from 'lodash-es'; 21import { debounce } from 'lodash-es';
22import { applySnapshot, getSnapshot, onSnapshot } from 'mobx-state-tree'; 22import { getSnapshot, onSnapshot } from 'mobx-state-tree';
23import ms from 'ms'; 23import ms from 'ms';
24 24
25import type ConfigPersistenceService from '../services/ConfigPersistenceService'; 25import type ConfigPersistenceService from '../services/ConfigPersistenceService.js';
26import type { Config, ConfigSnapshotOut } from '../stores/Config'; 26import { Config, ConfigFileIn, ConfigSnapshotOut } from '../stores/Config.js';
27import type Disposer from '../utils/Disposer'; 27import type Disposer from '../utils/Disposer';
28import { getLogger } from '../utils/log'; 28import { getLogger } from '../utils/log';
29 29
@@ -44,12 +44,14 @@ export default async function initConfig(
44 const result = await persistenceService.readConfig(); 44 const result = await persistenceService.readConfig();
45 if (result.found) { 45 if (result.found) {
46 try { 46 try {
47 applySnapshot(config, result.data); 47 // This cast is unsound if the config file is invalid,
48 lastSnapshotOnDisk = getSnapshot(config); 48 // but we'll throw an error in the end anyways.
49 config.loadFromConfigFile(result.data as ConfigFileIn);
49 } catch (error) { 50 } catch (error) {
50 log.error('Failed to apply config snapshot', result.data, error); 51 log.error('Failed to apply config snapshot', result.data, error);
51 } 52 }
52 } 53 }
54 lastSnapshotOnDisk = getSnapshot(config);
53 return result.found; 55 return result.found;
54 } 56 }
55 57