From 6b624dc264e1993b2e2668f1f1670e931b2886ac Mon Sep 17 00:00:00 2001 From: beerpiss Date: Wed, 26 Jun 2024 23:39:45 +0700 Subject: [PATCH] fix: properly clear out old config file before writing new one --- src/config/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/config/mod.rs b/src/config/mod.rs index 8f12cd0..3af5bf8 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -1,7 +1,7 @@ mod defaults; mod migrate; -use std::{collections::HashMap, path::PathBuf, str::FromStr}; +use std::{collections::HashMap, fs::File, path::PathBuf, str::FromStr}; use log::{info, warn}; use migrate::OldSaekawaConfig; @@ -76,6 +76,12 @@ impl SaekawaConfig { tachi: new_tachi_config, }; + { + // confy doesn't actually truncate the file?? + if let Ok(f) = File::create("saekawa.toml") { + f.set_len(0).ok(); + } + } confy::store_path("saekawa.toml", new_config.clone()).context(ConfySnafu)?; Ok(new_config)