mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
resolve issue #206 by adding check for existing basis
This commit is contained in:
parent
ef65d1aa9f
commit
9225cbaba3
6 changed files with 22 additions and 1 deletions
|
|
@ -29,6 +29,12 @@
|
|||
"zh": "选择要卸载的基础:",
|
||||
"en-tts": "Select the Bases to unmount:"
|
||||
},
|
||||
"vault.basis.already_exists": {
|
||||
"en": "Basis already exists! No action taken.",
|
||||
"ja": "ベースはすでに存在します! アクションは実行されません。",
|
||||
"zh": "基础已经存在! 不采取行动。",
|
||||
"en-tts": "Basis already exists! No action taken."
|
||||
},
|
||||
"vault.edit_dialog": {
|
||||
"en": "Make your changes and press enter.\nUse the d-pad to navigate entries.",
|
||||
"ja": "変更を加えてEnterキーを押します。 D-PADを使用してエントリをナビゲートします。",
|
||||
|
|
|
|||
|
|
@ -938,6 +938,9 @@ impl ActionManager {
|
|||
match self.pddb.borrow().unlock_basis(&name, Some(BasisRetentionPolicy::Persist)) {
|
||||
Ok(_) => log::debug!("Basis {} unlocked", name),
|
||||
Err(e) => match e.kind() {
|
||||
ErrorKind::AlreadyExists => {
|
||||
self.modals.show_notification(t!("vault.basis.already_exists", xous::LANG), None).ok();
|
||||
}
|
||||
ErrorKind::PermissionDenied => {
|
||||
self.report_err(t!("vault.error.basis_unlock_error", xous::LANG), None::<std::io::Error>)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -246,6 +246,7 @@ pub enum PddbRequestCode {
|
|||
InternalError = 8,
|
||||
AccessDenied = 9,
|
||||
Uninit = 10,
|
||||
DuplicateEntry = 11,
|
||||
}
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||
#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||
|
|
|
|||
|
|
@ -851,6 +851,11 @@ impl BasisCache {
|
|||
};
|
||||
|
||||
let basis_key = hw.basis_derive_key(name, password);
|
||||
|
||||
if let Some(_basis_map) = hw.pt_scan_key(&basis_key.pt, &basis_key.data, name) {
|
||||
return Err(Error::new(ErrorKind::AlreadyExists, "Basis already exists"));
|
||||
}
|
||||
|
||||
let mut basis_v2p_map = HashMap::<VirtAddr, PhysPage>::new();
|
||||
let basis_root = BasisRoot {
|
||||
magic: PDDB_MAGIC,
|
||||
|
|
|
|||
|
|
@ -221,6 +221,7 @@ impl Pddb {
|
|||
PddbRequestCode::NoErr => Ok(()),
|
||||
PddbRequestCode::NoFreeSpace => Err(Error::new(ErrorKind::OutOfMemory, "No free space to create basis")),
|
||||
PddbRequestCode::InternalError => Err(Error::new(ErrorKind::Other, "Internal error creating basis")),
|
||||
PddbRequestCode::DuplicateEntry => Err(Error::new(ErrorKind::AlreadyExists, "Basis already exists")),
|
||||
_ => {
|
||||
log::error!("Invalid return code");
|
||||
panic!("Invalid return code");
|
||||
|
|
|
|||
|
|
@ -769,7 +769,12 @@ fn wrapped_main() -> ! {
|
|||
log::info!("{}PDDB.CREATEOK,{},{}", xous::BOOKEND_START, mgmt.name.as_str().unwrap(), xous::BOOKEND_END);
|
||||
mgmt.code = PddbRequestCode::NoErr
|
||||
},
|
||||
_ => mgmt.code = PddbRequestCode::InternalError,
|
||||
Err(e) => match e.kind() {
|
||||
ErrorKind::AlreadyExists => {
|
||||
mgmt.code = PddbRequestCode::DuplicateEntry;
|
||||
}
|
||||
_ => mgmt.code = PddbRequestCode::InternalError,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mgmt.code = PddbRequestCode::InternalError;
|
||||
|
|
|
|||
Loading…
Reference in a new issue