From f02d959ebcf291f2fa7517e8de0aff03f6e707c5 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Tue, 25 Aug 2026 19:56:25 +0900 Subject: [PATCH] change: write config later --- dzgui/init/migrate.py | 6 +++--- dzgui/views/dialogs/wizard.py | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dzgui/init/migrate.py b/dzgui/init/migrate.py index 97c5587..19bfe8a 100644 --- a/dzgui/init/migrate.py +++ b/dzgui/init/migrate.py @@ -1,3 +1,4 @@ +import json import shutil from pathlib import Path @@ -7,11 +8,10 @@ from dzgui.config.convert import rc2json 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 j = rc2json(old_conf) - config.parent.mkdir(parents=True, exist_ok=True) - config.write_text(j) + return json.loads(j) def has_new_config(config: Path) -> bool: diff --git a/dzgui/views/dialogs/wizard.py b/dzgui/views/dialogs/wizard.py index 033f7a1..7837f4c 100644 --- a/dzgui/views/dialogs/wizard.py +++ b/dzgui/views/dialogs/wizard.py @@ -305,6 +305,7 @@ class ConfigMigrationPage(EnumeratedWizardPage): ) self.migrated = False + self.migrated_conf: dict[str, Any] = {} self.config = config self.page_type = Gtk.AssistantPageType.INTRO @@ -344,8 +345,7 @@ class ConfigMigrationPage(EnumeratedWizardPage): def _on_import_clicked(self, button: Gtk.Button) -> None: self.grid.set_sensitive(False) try: - # TODO: this could be deferred to the final page (prevents accidental destruction of dialog via ESC) - migrate_legacy_conf(self.config) + self.migrated_conf = migrate_legacy_conf(self.config) self.migrated = True self.success_box.set_visible(True) except Exception: @@ -496,9 +496,9 @@ class Assistant(Gtk.Assistant): pass case ConfigMigrationPage(): if page.is_migrated(): - steam_path = lookup(self.config_path, Preferences.DEFAULT) - self.page6.set_steam_path(steam_path) - offset = 1 if not self.is_binary else 2 + sp = page.migrated_conf["default_steam_path"] + self.page_shortcuts.set_steam_path(sp) + self.write_config(self.page_migration.migrated_conf) self.setup_complete = True return self.get_n_pages() - offset case SteamPathPage():