From 010577e6ccda41d626da498862abd6d5371bdc5b Mon Sep 17 00:00:00 2001 From: Bo Lopker Date: Thu, 22 Feb 2024 22:48:35 -0800 Subject: [PATCH] Fix first time config --- lib/config.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/config.dart b/lib/config.dart index c88b67d..95916ac 100644 --- a/lib/config.dart +++ b/lib/config.dart @@ -84,7 +84,7 @@ class Config { static void init() { signal.value = readConfig(); signals.effect(() { - print('Config changed: ${signal.value}'); + debugPrint('Config changed: ${signal.value}'); writeConfig(signal.value); }); } @@ -92,7 +92,7 @@ class Config { static ConfigData readConfig() { ensureConfigExists(); var configData = configFile.readAsStringSync(); - print('Read config: $configData'); + debugPrint('Read config: $configData'); return ConfigData.fromJson(jsonDecode(configData)); } @@ -103,10 +103,10 @@ class Config { static void ensureConfigExists() { if (!configDir.existsSync()) { - configDir.createSync(); + configDir.createSync(recursive: true); } - if (!configFile.existsSync()) { - configFile.writeAsStringSync('{}'); + if (!configFile.existsSync() || configFile.lengthSync() == 0) { + configFile.writeAsStringSync('{}', flush: true); } }