Skip to content

Commit 06913d0

Browse files
authored
fix(pedm): ensure get_last_request_time has a value (#1352)
The comments for [AboutData](https://github.com/Devolutions/devolutions-gateway/blob/668e0b43edd5ee2ce4cbf4692920c09d732eeb85/crates/devolutions-pedm/src/model.rs#L7) say > This can be `None` if `/about` is the first request made. Which is true and correct; but is causing a crash in the .NET OpenAPI client if /about is the first request made. For whatever reason, the .NET OpenAPI [generator](https://github.com/Devolutions/devolutions-gateway/blob/668e0b43edd5ee2ce4cbf4692920c09d732eeb85/crates/devolutions-pedm/openapi/dotnet-client/src/Devolutions.Pedm.Client/Model/AboutData.cs#L74) is not creating a nullable property. This may be related to the issues I had in #1164, but I don't have time to dig into it now. Since this is non-critical / non-user facing; I just force a value here for the first request (the UNIX epoch seems reasonable).
1 parent 668e0b4 commit 06913d0

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

crates/devolutions-pedm/src/api/about.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::sync::atomic::Ordering;
33
use aide::NoApi;
44
use axum::extract::State;
55
use axum::Json;
6+
use chrono::{TimeZone, Utc};
67

78
use crate::db::Db;
89
use crate::model::AboutData;
@@ -20,7 +21,10 @@ pub(crate) async fn about(
2021
start_time: state.startup_info.start_time,
2122
startup_request_count: state.startup_info.request_count,
2223
current_request_count: state.req_counter.load(Ordering::Relaxed),
23-
last_request_time: db.get_last_request_time().await?,
24+
last_request_time: db
25+
.get_last_request_time()
26+
.await?
27+
.or_else(|| Some(Utc.timestamp_opt(0, 0).single().unwrap())),
2428
version: win_api_wrappers::utils::get_exe_version()?,
2529
}))
2630
}

0 commit comments

Comments
 (0)