refactor(config): use generate_default_toml() from constants for initial config

This commit is contained in:
sankalp committed 2026-07-30 22:52:00 +05:45
1 parent f93f5f8942
commit 4a9f8fc1b8
1 file changed
+5 -3
+5 -3
View File
@@ -14,6 +14,7 @@ from tomlkit import document as toml_document
from tomlkit import dump as toml_dump
from tomlkit import item as toml_item
from tomlkit import load as toml_load
from tomlkit import loads as toml_loads
from utils.gtk_utils import toml_file
@@ -126,12 +127,13 @@ class ConfigService:
self._config = toml_load(f)
else:
try:
from utils.constants import DEFAULT
from utils.constants import generate_default_toml
os.makedirs(os.path.dirname(self._config_file), exist_ok=True)
self._config = self._dict_to_toml(DEFAULT)
raw = generate_default_toml()
self._config = toml_loads(raw)
with open(self._config_file, "w") as f:
toml_dump(self._config, f)
f.write(raw)
logger.info(
f"[ConfigService] Generated default config at {self._config_file}"
)