From ea5ba750d473fe3d8501077dab56eb78aba0eff2 Mon Sep 17 00:00:00 2001 From: lubeilin <1791778603@qq.com> Date: Tue, 9 May 2023 22:47:59 +0800 Subject: [PATCH] sync --- switch-desktop/src/config/mod.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/switch-desktop/src/config/mod.rs b/switch-desktop/src/config/mod.rs index bc068a0..244aa76 100644 --- a/switch-desktop/src/config/mod.rs +++ b/switch-desktop/src/config/mod.rs @@ -188,7 +188,9 @@ impl ArgsConfig { pub fn lock_file() -> io::Result { let path = SWITCH_HOME_PATH.lock().clone().unwrap().join(".lock"); - Ok(File::create(path)?) + let file = File::create(path)?; + file.sync_all()?; + Ok(file) } pub fn save_config(config: ArgsConfig) -> io::Result<()> { @@ -198,10 +200,11 @@ pub fn save_config(config: ArgsConfig) -> io::Result<()> { fn save_config_(config: ArgsConfig, config_path: PathBuf) -> io::Result<()> { let mut config_lock = CONFIG.lock(); - config_lock.take(); + config_lock.replace(config.clone()); let str = serde_yaml::to_string(&config).unwrap(); let mut file = File::create(config_path)?; - file.write_all(str.as_bytes()) + file.write_all(str.as_bytes())?; + file.sync_all() } pub fn update_pid(pid: u32) -> io::Result<()> {