more idiomatic current_time determination
This commit is contained in:
parent
2fa6935820
commit
41b397a909
@ -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| {
|
||||||
|
println!("rtc module error: {:?}", err);
|
||||||
|
board.general_fault(true);
|
||||||
|
board.time()
|
||||||
|
}).map_err(|err| -> Result<(), _>{
|
||||||
|
bail!("time error {}", err);
|
||||||
|
}).unwrap();
|
||||||
|
|
||||||
let mut cur = match board.get_rtc_time() {
|
//check if we know the time current > 2020 (plausibility check, this code is newer than 2020)
|
||||||
Ok(time) => time,
|
|
||||||
Err(err) => {
|
|
||||||
println!("rtc module error: {}", err);
|
|
||||||
board.general_fault(true);
|
|
||||||
let time = board.time();
|
|
||||||
match time {
|
|
||||||
Ok(cur) => cur,
|
|
||||||
Err(err) => {
|
|
||||||
bail!("time error {}", err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//check if we know the time current > 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 :(");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user