delay lock until it is needed
This commit is contained in:
parent
7f62c9b6a8
commit
92d756741a
1 changed files with 1 additions and 1 deletions
|
@ -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())
|
||||
|
|
Loading…
Reference in a new issue