mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
convert MtxChat::get(&mut self) to MtxChat::get(&self)
This commit is contained in:
parent
2a1be321e9
commit
8a05e32e86
1 changed files with 12 additions and 7 deletions
|
|
@ -77,6 +77,17 @@ impl MtxChat {
|
||||||
filter: EMPTY.to_string(),
|
filter: EMPTY.to_string(),
|
||||||
since: EMPTY.to_string(),
|
since: EMPTY.to_string(),
|
||||||
};
|
};
|
||||||
|
let mut keypath = PathBuf::new();
|
||||||
|
keypath.push(MTXCHAT_DICT);
|
||||||
|
if std::fs::metadata(&keypath).is_ok() { // keypath exists
|
||||||
|
// log::info!("dict '{}' exists", MTXCHAT_DICT);
|
||||||
|
} else {
|
||||||
|
log::info!("dict '{}' does NOT exist.. creating it", MTXCHAT_DICT);
|
||||||
|
match std::fs::create_dir_all(&keypath){
|
||||||
|
Ok(_) => log::info!("created dict: {}", MTXCHAT_DICT),
|
||||||
|
Err(e) => log::warn!("failed to create dict: {:?}", e),
|
||||||
|
}
|
||||||
|
}
|
||||||
common
|
common
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -247,18 +258,12 @@ impl MtxChat {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get(&mut self, key: &str) -> Result<Option<String>, Error> {
|
pub fn get(&self, key: &str) -> Result<Option<String>, Error> {
|
||||||
// if key.eq(CURRENT_VERSION_KEY) {
|
// if key.eq(CURRENT_VERSION_KEY) {
|
||||||
// Ok(Some(self.version.clone()))
|
// Ok(Some(self.version.clone()))
|
||||||
// } else {
|
// } else {
|
||||||
let mut keypath = PathBuf::new();
|
let mut keypath = PathBuf::new();
|
||||||
keypath.push(MTXCHAT_DICT);
|
keypath.push(MTXCHAT_DICT);
|
||||||
if std::fs::metadata(&keypath).is_ok() { // keypath exists
|
|
||||||
// log::info!("dict '{}' exists", MTXCHAT_DICT);
|
|
||||||
} else {
|
|
||||||
log::info!("dict '{}' does NOT exist.. creating it", MTXCHAT_DICT);
|
|
||||||
std::fs::create_dir_all(&keypath)?;
|
|
||||||
}
|
|
||||||
keypath.push(key);
|
keypath.push(key);
|
||||||
if let Ok(mut file) = File::open(keypath) {
|
if let Ok(mut file) = File::open(keypath) {
|
||||||
let mut value = String::new();
|
let mut value = String::new();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue