mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +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": "选择要卸载的基础:",
|
"zh": "选择要卸载的基础:",
|
||||||
"en-tts": "Select the Bases to unmount:"
|
"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": {
|
"vault.edit_dialog": {
|
||||||
"en": "Make your changes and press enter.\nUse the d-pad to navigate entries.",
|
"en": "Make your changes and press enter.\nUse the d-pad to navigate entries.",
|
||||||
"ja": "変更を加えてEnterキーを押します。 D-PADを使用してエントリをナビゲートします。",
|
"ja": "変更を加えてEnterキーを押します。 D-PADを使用してエントリをナビゲートします。",
|
||||||
|
|
|
||||||
|
|
@ -938,6 +938,9 @@ impl ActionManager {
|
||||||
match self.pddb.borrow().unlock_basis(&name, Some(BasisRetentionPolicy::Persist)) {
|
match self.pddb.borrow().unlock_basis(&name, Some(BasisRetentionPolicy::Persist)) {
|
||||||
Ok(_) => log::debug!("Basis {} unlocked", name),
|
Ok(_) => log::debug!("Basis {} unlocked", name),
|
||||||
Err(e) => match e.kind() {
|
Err(e) => match e.kind() {
|
||||||
|
ErrorKind::AlreadyExists => {
|
||||||
|
self.modals.show_notification(t!("vault.basis.already_exists", xous::LANG), None).ok();
|
||||||
|
}
|
||||||
ErrorKind::PermissionDenied => {
|
ErrorKind::PermissionDenied => {
|
||||||
self.report_err(t!("vault.error.basis_unlock_error", xous::LANG), None::<std::io::Error>)
|
self.report_err(t!("vault.error.basis_unlock_error", xous::LANG), None::<std::io::Error>)
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -246,6 +246,7 @@ pub enum PddbRequestCode {
|
||||||
InternalError = 8,
|
InternalError = 8,
|
||||||
AccessDenied = 9,
|
AccessDenied = 9,
|
||||||
Uninit = 10,
|
Uninit = 10,
|
||||||
|
DuplicateEntry = 11,
|
||||||
}
|
}
|
||||||
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||||
#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||||
|
|
|
||||||
|
|
@ -851,6 +851,11 @@ impl BasisCache {
|
||||||
};
|
};
|
||||||
|
|
||||||
let basis_key = hw.basis_derive_key(name, password);
|
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 mut basis_v2p_map = HashMap::<VirtAddr, PhysPage>::new();
|
||||||
let basis_root = BasisRoot {
|
let basis_root = BasisRoot {
|
||||||
magic: PDDB_MAGIC,
|
magic: PDDB_MAGIC,
|
||||||
|
|
|
||||||
|
|
@ -221,6 +221,7 @@ impl Pddb {
|
||||||
PddbRequestCode::NoErr => Ok(()),
|
PddbRequestCode::NoErr => Ok(()),
|
||||||
PddbRequestCode::NoFreeSpace => Err(Error::new(ErrorKind::OutOfMemory, "No free space to create basis")),
|
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::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");
|
log::error!("Invalid return code");
|
||||||
panic!("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);
|
log::info!("{}PDDB.CREATEOK,{},{}", xous::BOOKEND_START, mgmt.name.as_str().unwrap(), xous::BOOKEND_END);
|
||||||
mgmt.code = PddbRequestCode::NoErr
|
mgmt.code = PddbRequestCode::NoErr
|
||||||
},
|
},
|
||||||
_ => mgmt.code = PddbRequestCode::InternalError,
|
Err(e) => match e.kind() {
|
||||||
|
ErrorKind::AlreadyExists => {
|
||||||
|
mgmt.code = PddbRequestCode::DuplicateEntry;
|
||||||
|
}
|
||||||
|
_ => mgmt.code = PddbRequestCode::InternalError,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mgmt.code = PddbRequestCode::InternalError;
|
mgmt.code = PddbRequestCode::InternalError;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue