more idiomatic current_time determination

This commit is contained in:
ju6ge 2025-02-27 22:44:19 +01:00
parent 2fa6935820
commit 41b397a909
Signed by: judge
GPG Key ID: 6512C30DD8E017B5

View File

@ -242,23 +242,15 @@ fn safe_main() -> anyhow::Result<()> {
log(log::LogMessage::FilesystemMount, free_space.free_size as u32, log(log::LogMessage::FilesystemMount, free_space.free_size as u32,
free_space.total_size as u32, &free_space.used_size.to_string(), ""); free_space.total_size as u32, &free_space.used_size.to_string(), "");
let mut cur = board.get_rtc_time().or_else(|err| {
let mut cur = match board.get_rtc_time() { println!("rtc module error: {:?}", err);
Ok(time) => time,
Err(err) => {
println!("rtc module error: {}", err);
board.general_fault(true); board.general_fault(true);
let time = board.time(); board.time()
match time { }).map_err(|err| -> Result<(), _>{
Ok(cur) => cur,
Err(err) => {
bail!("time error {}", err); bail!("time error {}", err);
} }).unwrap();
}
}
};
//check if we know the time current > 2020 //check if we know the time current > 2020 (plausibility check, this code is newer than 2020)
if cur.year() < 2020 { if cur.year() < 2020 {
to_config = true; to_config = true;
log(log::LogMessage::YearInplausibleForceConfig, 0,0,"",""); log(log::LogMessage::YearInplausibleForceConfig, 0,0,"","");
@ -988,7 +980,7 @@ fn main() {
// if safe_main exists with error, rollback to known good ota version // if safe_main exists with error, rollback to known good ota version
Err(err) => { Err(err) => {
println!("Failed main {}", err); println!("Failed main {}", err);
let rollback_successful = rollback_and_reboot(); let _rollback_successful = rollback_and_reboot();
panic!("Failed to rollback :("); panic!("Failed to rollback :(");
} }
} }