handle_static_file_download: move from and_then to await
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
4e8cff1c9d
commit
9c18e93522
|
@ -439,16 +439,15 @@ async fn chuncked_static_file_download(filename: PathBuf) -> Result<Response<Bod
|
||||||
|
|
||||||
async fn handle_static_file_download(filename: PathBuf) -> Result<Response<Body>, Error> {
|
async fn handle_static_file_download(filename: PathBuf) -> Result<Response<Body>, Error> {
|
||||||
|
|
||||||
tokio::fs::metadata(filename.clone())
|
let metadata = tokio::fs::metadata(filename.clone())
|
||||||
.map_err(|err| http_err!(BAD_REQUEST, format!("File access problems: {}", err)))
|
.map_err(|err| http_err!(BAD_REQUEST, format!("File access problems: {}", err)))
|
||||||
.and_then(|metadata| async move {
|
.await?;
|
||||||
|
|
||||||
if metadata.len() < 1024*32 {
|
if metadata.len() < 1024*32 {
|
||||||
simple_static_file_download(filename).await
|
simple_static_file_download(filename).await
|
||||||
} else {
|
} else {
|
||||||
chuncked_static_file_download(filename).await
|
chuncked_static_file_download(filename).await
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.await
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extract_auth_data(headers: &http::HeaderMap) -> (Option<String>, Option<String>) {
|
fn extract_auth_data(headers: &http::HeaderMap) -> (Option<String>, Option<String>) {
|
||||||
|
|
Loading…
Reference in New Issue