mtxchat simplify create pddb::dict mtxchat

This commit is contained in:
nworbnhoj 2023-09-08 18:01:00 +10:00
parent a7d3b34563
commit e1f1ac427b

View file

@ -100,27 +100,13 @@ impl<'a> MtxChat<'a> {
listening: false, listening: false,
modals: modals, modals: modals,
}; };
let mut keypath = PathBuf::new();
keypath.push(MTXCHAT_DICT); // create the mtxchat dict if it does not exist
if !std::fs::metadata(&keypath).is_ok() { let pddb = pddb::Pddb::new();
common.modals pddb.try_mount();
.show_notification("mtxchat dict DOES NOT exist", None) match pddb.get(MTXCHAT_DICT, USER_DOMAIN_KEY, None, true, false, None, None::<fn()>) {
.expect("notification failed"); Ok(_) => {}
log::info!("dict '{}' does NOT exist.. creating it", MTXCHAT_DICT); Err(e) => log::warn!("failed to create dict: {:?}", e),
match std::fs::create_dir_all(&keypath) {
Ok(_) => {
common.modals
.show_notification("created mtxchat dict", None)
.expect("notification failed");
log::info!("created dict: {}", MTXCHAT_DICT);
}
Err(e) => {
common.modals
.show_notification("failed to creat mtxchat dict", None)
.expect("notification failed");
log::warn!("failed to create dict: {:?}", e);
}
}
} }
common common
} }