From 01fe88e3371ef66ffa2f11776aaad0cd99324ce7 Mon Sep 17 00:00:00 2001 From: link2xt Date: Tue, 10 Jan 2023 01:36:05 +0000 Subject: [PATCH] Save modified .toml if absolute paths were replaced with relative Previously this required adding or removing an account. --- CHANGELOG.md | 1 + src/accounts.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf4f53026..942ac2a86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### Fixes - fix: only send contact changed event for recently seen if it is relevant (not too old to matter) #3938 +- Immediately save `accounts.toml` if it was modified by a migration from absolute paths to relative paths #3943 ## 1.105.0 diff --git a/src/accounts.rs b/src/accounts.rs index 2380de04e..8de0a7da8 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -367,13 +367,20 @@ impl Config { // Previous versions of the core stored absolute paths in account config. // Convert them to relative paths. + let mut modified = false; for account in &mut inner.accounts { if let Ok(new_dir) = account.dir.strip_prefix(dir) { account.dir = new_dir.to_path_buf(); + modified = true; } } - Ok(Config { file, inner }) + let config = Self { file, inner }; + if modified { + config.sync().await?; + } + + Ok(config) } /// Loads all accounts defined in the configuration file.