From 3eeba082483c06318ca7a1f018ce2c5da47f5f32 Mon Sep 17 00:00:00 2001 From: edouard Date: Tue, 4 Apr 2023 12:54:27 +0200 Subject: [PATCH] fix not found settings file error for old gui versions. After migrating from a 0.1 or 0.2 version of the gui user may want to update the keys aliases in the settings This commit makes sure that a settings file exists when wallet is loaded. --- gui/src/app/settings.rs | 1 + gui/src/app/wallet.rs | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gui/src/app/settings.rs b/gui/src/app/settings.rs index 3ff3dc29..f8a077db 100644 --- a/gui/src/app/settings.rs +++ b/gui/src/app/settings.rs @@ -47,6 +47,7 @@ impl Settings { let mut settings_file = OpenOptions::new() .write(true) + .create(true) .truncate(true) .open(path) .map_err(|e| SettingsError::WritingFile(e.to_string()))?; diff --git a/gui/src/app/wallet.rs b/gui/src/app/wallet.rs index 421b8798..da23a4ca 100644 --- a/gui/src/app/wallet.rs +++ b/gui/src/app/wallet.rs @@ -91,7 +91,16 @@ impl Wallet { self.with_hardware_wallets(gui_config_hws) } } - Err(settings::SettingsError::NotFound) => self.with_hardware_wallets(gui_config_hws), + Err(settings::SettingsError::NotFound) => { + let wallet = self.with_hardware_wallets(gui_config_hws); + let s = settings::Settings { + wallets: vec![settings::WalletSetting::from(&wallet)], + }; + + tracing::info!("Settings file not found, creating one"); + s.to_file(datadir_path.to_path_buf(), network)?; + wallet + } Err(e) => return Err(e.into()), };