Use "_" instead of ":" in PeerConfig filenames
This commit is contained in:
parent
18a801e3b2
commit
e1516d809f
@ -1,5 +1,6 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
|
ffi::{OsStr, OsString},
|
||||||
fs,
|
fs,
|
||||||
net::{IpAddr, Ipv4Addr, SocketAddr},
|
net::{IpAddr, Ipv4Addr, SocketAddr},
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
@ -848,7 +849,7 @@ impl PeerConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn path(id: &str) -> PathBuf {
|
fn path(id: &str) -> PathBuf {
|
||||||
let path: PathBuf = [PEERS, id].iter().collect();
|
let path: PathBuf = [PEERS, id.replace(":", "_").as_str()].iter().collect();
|
||||||
Config::with_extension(Config::path(path))
|
Config::with_extension(Config::path(path))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -870,7 +871,22 @@ impl PeerConfig {
|
|||||||
.file_stem()
|
.file_stem()
|
||||||
.map(|p| p.to_str().unwrap_or(""))
|
.map(|p| p.to_str().unwrap_or(""))
|
||||||
.unwrap_or("")
|
.unwrap_or("")
|
||||||
|
.replace("_", ":")
|
||||||
.to_owned();
|
.to_owned();
|
||||||
|
|
||||||
|
//rename PeerConfig files if they contain ":"
|
||||||
|
//to stay backward compatible with *nix
|
||||||
|
let current_filename = p
|
||||||
|
.file_name()
|
||||||
|
.unwrap_or(OsStr::new(""))
|
||||||
|
.to_str()
|
||||||
|
.unwrap_or("");
|
||||||
|
if current_filename.contains(":") {
|
||||||
|
if let Some(path) = p.parent() {
|
||||||
|
fs::rename(p, path.join(current_filename.replace(":", "_"))).ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let c = PeerConfig::load(&id);
|
let c = PeerConfig::load(&id);
|
||||||
if c.info.platform.is_empty() {
|
if c.info.platform.is_empty() {
|
||||||
fs::remove_file(&p).ok();
|
fs::remove_file(&p).ok();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user