From f36f0f7530befed84238fece87172231980d1ea7 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Fri, 10 Jun 2022 18:25:25 +0800 Subject: [PATCH] https://github.com/rustdesk/rustdesk/issues/701 --- libs/hbb_common/src/config.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libs/hbb_common/src/config.rs b/libs/hbb_common/src/config.rs index ce0fc509a..1c14be303 100644 --- a/libs/hbb_common/src/config.rs +++ b/libs/hbb_common/src/config.rs @@ -271,7 +271,7 @@ impl Config { fn file_(suffix: &str) -> PathBuf { let name = format!("{}{}", *APP_NAME.read().unwrap(), suffix); - Self::path(name).with_extension("toml") + Config::with_extension(Self::path(name)) } pub fn get_home() -> PathBuf { @@ -687,6 +687,16 @@ impl Config { lock.store(); true } + + fn with_extension(path: PathBuf) -> PathBuf { + let ext = path.extension(); + if let Some(ext) = ext { + let ext = format!("{}.toml", ext.to_string_lossy()); + path.with_extension(&ext) + } else { + path.with_extension("toml") + } + } } const PEERS: &str = "peers"; @@ -716,7 +726,7 @@ impl PeerConfig { fn path(id: &str) -> PathBuf { let path: PathBuf = [PEERS, id].iter().collect(); - Config::path(path).with_extension("toml") + Config::with_extension(Config::path(path)) } pub fn peers() -> Vec<(String, SystemTime, PeerConfig)> {