delay lock until it is needed
parent
7f62c9b6a8
commit
92d756741a
|
@ -21,7 +21,6 @@ async fn download(
|
||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
) -> Result<axum::response::Response, (StatusCode, String)> {
|
) -> Result<axum::response::Response, (StatusCode, String)> {
|
||||||
{
|
{
|
||||||
let mut records = state.records.lock().await;
|
|
||||||
if headers.get("hx-request").is_some() {
|
if headers.get("hx-request").is_some() {
|
||||||
return Ok(axum::http::Response::builder()
|
return Ok(axum::http::Response::builder()
|
||||||
.header("HX-Redirect", format!("/download/{id}"))
|
.header("HX-Redirect", format!("/download/{id}"))
|
||||||
|
@ -31,6 +30,7 @@ async fn download(
|
||||||
.into_response());
|
.into_response());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut records = state.records.lock().await;
|
||||||
if let Some(record) = records
|
if let Some(record) = records
|
||||||
.get_mut(&id)
|
.get_mut(&id)
|
||||||
.filter(|record| record.can_be_downloaded())
|
.filter(|record| record.can_be_downloaded())
|
||||||
|
|
Loading…
Reference in New Issue