1
0
Fork 0

delay lock until it is needed

Zynh Ludwig 2024-08-30 23:08:32 -07:00
parent 7f62c9b6a8
commit 92d756741a
1 changed files with 1 additions and 1 deletions

View File

@ -21,7 +21,6 @@ async fn download(
State(state): State<AppState>,
) -> Result<axum::response::Response, (StatusCode, String)> {
{
let mut records = state.records.lock().await;
if headers.get("hx-request").is_some() {
return Ok(axum::http::Response::builder()
.header("HX-Redirect", format!("/download/{id}"))
@ -31,6 +30,7 @@ async fn download(
.into_response());
}
let mut records = state.records.lock().await;
if let Some(record) = records
.get_mut(&id)
.filter(|record| record.can_be_downloaded())