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) => { Ok(mut data) => {
match data.write(&ser) { match data.write(&ser) {
Ok(_) => {} Ok(len) => log::debug!("wrote {} bytes", len),
Err(e) => { Err(e) => {
self.modals.show_notification(&format!("{}\n{:?}", self.modals.show_notification(&format!("{}\n{:?}",
t!("vault.error.internal_error", xous::LANG), e t!("vault.error.internal_error", xous::LANG), e
@ -319,6 +319,7 @@ impl ActionManager {
), None).ok(); ), None).ok();
} }
} }
log::info!("syncing...");
self.pddb.borrow().sync().ok(); self.pddb.borrow().sync().ok();
} }
_ => {} // not valid for these other modes _ => {} // 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> { 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, "version", record.version,
"description", record.description, "description", record.description,
"username", record.username, "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) { if let Ok(ver) = u32::from_str_radix(data, 10) {
pr.version = ver pr.version = ver
} else { } else {
log::warn!("ver error");
return None; 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) { if let Ok(ctime) = u64::from_str_radix(data, 10) {
pr.ctime = ctime; pr.ctime = ctime;
} else { } else {
log::warn!("ctime error");
return None; 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) { if let Ok(atime) = u64::from_str_radix(data, 10) {
pr.atime = atime; pr.atime = atime;
} else { } else {
log::warn!("atime error");
return None; 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) { if let Ok(count) = u64::from_str_radix(data, 10) {
pr.count = count; pr.count = count;
} else { } else {
log::warn!("count error");
return None; return None;
} }
} }

View file

@ -209,8 +209,10 @@ fn main() -> ! {
let xns = xous_names::XousNames::new().unwrap(); let xns = xous_names::XousNames::new().unwrap();
// TODO: add a UX loop that indicates we're waiting for a PDDB mount before moving forward // 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()); 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 // Trigger the mode update in the actions
log::info!("vaultux created");
send_message(actions_conn, send_message(actions_conn,
Message::new_blocking_scalar(ActionOp::UpdateMode.to_usize().unwrap(), 0, 0, 0, 0) Message::new_blocking_scalar(ActionOp::UpdateMode.to_usize().unwrap(), 0, 0, 0, 0)
).ok(); ).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> { 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, "name", appinfo.name,
"id", hex::encode(appinfo.id), "id", hex::encode(appinfo.id),
"ctime", appinfo.ctime, "ctime", appinfo.ctime,

View file

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