优化代码

This commit is contained in:
lubeilin
2023-03-19 20:11:51 +08:00
parent d7226d8522
commit 7840f30b64
14 changed files with 174 additions and 99 deletions
+3 -4
View File
@@ -156,10 +156,9 @@ impl ArgsConfig {
}
}
}
use fd_lock::RwLock;
pub fn lock_config() -> io::Result<RwLock<File>> {
let config_path = SWITCH_HOME_PATH.lock().clone().unwrap().join("config");
Ok(RwLock::new(File::open(config_path)?))
pub fn lock_file() -> io::Result<File> {
let path = SWITCH_HOME_PATH.lock().clone().unwrap().join(".lock");
Ok(File::create(path)?)
}
pub fn save_config(config: ArgsConfig) -> io::Result<()> {