change: write config later

This commit is contained in:
aclist committed 2026-08-25 19:57:07 +09:00
1 parent 04e9e5dcf0
commit f02d959ebc
2 files changed
+8 -8

No files matched your search

+3 -3
View File
@@ -1,3 +1,4 @@
import json
import shutil import shutil
from pathlib import Path from pathlib import Path
@@ -7,11 +8,10 @@ from dzgui.config.convert import rc2json
from dzgui.util._json import read_json, write_json from dzgui.util._json import read_json, write_json
def migrate_legacy_conf(config: Path) -> None: def migrate_legacy_conf(config: Path) -> dict[str, Any]:
old_conf = Path.home() / LEGACY_CONFIG_PATH old_conf = Path.home() / LEGACY_CONFIG_PATH
j = rc2json(old_conf) j = rc2json(old_conf)
config.parent.mkdir(parents=True, exist_ok=True) return json.loads(j)
config.write_text(j)
def has_new_config(config: Path) -> bool: def has_new_config(config: Path) -> bool:
+5 -5
View File
@@ -305,6 +305,7 @@ class ConfigMigrationPage(EnumeratedWizardPage):
) )
self.migrated = False self.migrated = False
self.migrated_conf: dict[str, Any] = {}
self.config = config self.config = config
self.page_type = Gtk.AssistantPageType.INTRO self.page_type = Gtk.AssistantPageType.INTRO
@@ -344,8 +345,7 @@ class ConfigMigrationPage(EnumeratedWizardPage):
def _on_import_clicked(self, button: Gtk.Button) -> None: def _on_import_clicked(self, button: Gtk.Button) -> None:
self.grid.set_sensitive(False) self.grid.set_sensitive(False)
try: try:
# TODO: this could be deferred to the final page (prevents accidental destruction of dialog via ESC) self.migrated_conf = migrate_legacy_conf(self.config)
migrate_legacy_conf(self.config)
self.migrated = True self.migrated = True
self.success_box.set_visible(True) self.success_box.set_visible(True)
except Exception: except Exception:
@@ -496,9 +496,9 @@ class Assistant(Gtk.Assistant):
pass pass
case ConfigMigrationPage(): case ConfigMigrationPage():
if page.is_migrated(): if page.is_migrated():
steam_path = lookup(self.config_path, Preferences.DEFAULT) sp = page.migrated_conf["default_steam_path"]
self.page6.set_steam_path(steam_path) self.page_shortcuts.set_steam_path(sp)
offset = 1 if not self.is_binary else 2 self.write_config(self.page_migration.migrated_conf)
self.setup_complete = True self.setup_complete = True
return self.get_n_pages() - offset return self.get_n_pages() - offset
case SteamPathPage(): case SteamPathPage():