log key refresh better

This commit is contained in:
Alex Janka 2024-01-12 08:47:19 +11:00
parent 429a233974
commit 904513b71a

View file

@ -195,11 +195,15 @@ impl TeslaInterface {
async fn refresh_keys(&mut self) {
// refresh our Tesla (the company's web servers, not the car) access token
if Instant::now().duration_since(self.last_refresh) >= KEY_REFRESH_INTERVAL {
log::warn!("refreshing keys...");
match self.api.refresh().await {
Ok(_) => {
let now = Instant::now();
match self.save_key() {
Ok(_) => self.last_refresh = now,
Ok(_) => {
log::warn!("refreshed keys...");
self.last_refresh = now;
}
Err(e) => error!("error saving auth token: {e:?}"),
}
}