Save modified .toml if absolute paths were replaced with relative

Previously this required adding or removing an account.
This commit is contained in:
link2xt
2023-01-10 01:36:05 +00:00
parent 2b8923931e
commit 01fe88e337
2 changed files with 9 additions and 1 deletions

View File

@@ -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.