add trailing newline to serializations

the final entry can accrue cruft after it if there is no newline
This commit is contained in:
bunnie 2022-06-23 04:11:58 +08:00
parent 57f9e1a5f9
commit 8c986035b8
4 changed files with 12 additions and 4 deletions

View file

@ -305,7 +305,7 @@ impl ActionManager {
) {
Ok(mut data) => {
match data.write(&ser) {
Ok(_) => {}
Ok(len) => log::debug!("wrote {} bytes", len),
Err(e) => {
self.modals.show_notification(&format!("{}\n{:?}",
t!("vault.error.internal_error", xous::LANG), e
@ -319,6 +319,7 @@ impl ActionManager {
), None).ok();
}
}
log::info!("syncing...");
self.pddb.borrow().sync().ok();
}
_ => {} // not valid for these other modes
@ -700,7 +701,7 @@ fn length_validator(input: TextEntryPayload) -> Option<xous_ipc::String<256>> {
}
pub(crate) fn serialize_password<'a>(record: &PasswordRecord) -> Vec::<u8> {
format!("{}:{}\n{}:{}\n{}:{}\n{}:{}\n{}:{}\n{}:{}\n{}:{}\n{}:{}",
format!("{}:{}\n{}:{}\n{}:{}\n{}:{}\n{}:{}\n{}:{}\n{}:{}\n{}:{}\n",
"version", record.version,
"description", record.description,
"username", record.username,
@ -732,6 +733,7 @@ pub(crate) fn deserialize_password(data: Vec::<u8>) -> Option<PasswordRecord> {
if let Ok(ver) = u32::from_str_radix(data, 10) {
pr.version = ver
} else {
log::warn!("ver error");
return None;
}
}
@ -743,6 +745,7 @@ pub(crate) fn deserialize_password(data: Vec::<u8>) -> Option<PasswordRecord> {
if let Ok(ctime) = u64::from_str_radix(data, 10) {
pr.ctime = ctime;
} else {
log::warn!("ctime error");
return None;
}
}
@ -750,6 +753,7 @@ pub(crate) fn deserialize_password(data: Vec::<u8>) -> Option<PasswordRecord> {
if let Ok(atime) = u64::from_str_radix(data, 10) {
pr.atime = atime;
} else {
log::warn!("atime error");
return None;
}
}
@ -757,6 +761,7 @@ pub(crate) fn deserialize_password(data: Vec::<u8>) -> Option<PasswordRecord> {
if let Ok(count) = u64::from_str_radix(data, 10) {
pr.count = count;
} else {
log::warn!("count error");
return None;
}
}

View file

@ -209,8 +209,10 @@ fn main() -> ! {
let xns = xous_names::XousNames::new().unwrap();
// TODO: add a UX loop that indicates we're waiting for a PDDB mount before moving forward
log::info!("creating vaultux");
let mut vaultux = VaultUx::new(&xns, sid, menu_mgr, actions_conn, mode.clone(), item_list, action_active.clone());
// Trigger the mode update in the actions
log::info!("vaultux created");
send_message(actions_conn,
Message::new_blocking_scalar(ActionOp::UpdateMode.to_usize().unwrap(), 0, 0, 0, 0)
).ok();

View file

@ -568,7 +568,7 @@ pub(crate) fn deserialize_app_info(descriptor: Vec::<u8>) -> Option::<AppInfo> {
}
pub(crate) fn serialize_app_info<'a>(appinfo: &AppInfo) -> Vec::<u8> {
format!("{}:{}\n{}:{}\n{}:{}\n{}:{}\n{}:{}",
format!("{}:{}\n{}:{}\n{}:{}\n{}:{}\n{}:{}\n",
"name", appinfo.name,
"id", hex::encode(appinfo.id),
"ctime", appinfo.ctime,

View file

@ -183,6 +183,7 @@ impl VaultUx {
usb_dev: usb_device_xous::UsbHid::new(),
}
}
pub(crate) fn update_mode(&mut self) {
self.title_dirty = true;
self.filtered_list.clear();
@ -248,7 +249,7 @@ impl VaultUx {
let style = match self.pddb.borrow().get(
VAULT_CONFIG_DICT,
VAULT_CONFIG_KEY_FONT,
None, true, false,
None, true, true,
Some(32), Some(crate::basis_change)
) {
Ok(mut style_key) => {