fix web show dup entry for same machine (#526)

This commit is contained in:
Sijie.Sun
2024-12-21 11:51:01 -05:00
committed by GitHub
parent 4e5915f98e
commit 4cf61f0d4a
7 changed files with 82 additions and 30 deletions
+14 -4
View File
@@ -1,4 +1,4 @@
use std::{fmt::Debug, sync::Arc};
use std::{fmt::Debug, str::FromStr as _, sync::Arc};
use easytier::{
common::scoped_task::ScopedTask,
@@ -87,10 +87,20 @@ impl WebServerService for SessionRpcService {
.map(Into::into)
.unwrap_or(uuid::Uuid::new_v4()),
});
if let Ok(storage) = Storage::try_from(data.storage.clone()) {
storage.add_client(data.storage_token.as_ref().unwrap().clone());
}
}
if let Ok(storage) = Storage::try_from(data.storage.clone()) {
let Ok(report_time) = chrono::DateTime::<chrono::Local>::from_str(&req.report_time)
else {
tracing::error!("Failed to parse report time: {:?}", req.report_time);
return Ok(HeartbeatResponse {});
};
storage.update_client(
data.storage_token.as_ref().unwrap().clone(),
report_time.timestamp(),
);
}
let _ = data.notifier.send(req);
Ok(HeartbeatResponse {})
}