From 9c18e93522e4c7a0cd1abd3e34d582ac0fd93dfe Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Tue, 17 Dec 2019 08:56:52 +0100 Subject: [PATCH] handle_static_file_download: move from and_then to await Signed-off-by: Thomas Lamprecht --- src/server/rest.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/server/rest.rs b/src/server/rest.rs index 8d82f855..80c594c8 100644 --- a/src/server/rest.rs +++ b/src/server/rest.rs @@ -439,16 +439,15 @@ async fn chuncked_static_file_download(filename: PathBuf) -> Result Result, 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))) - .and_then(|metadata| async move { - if metadata.len() < 1024*32 { - simple_static_file_download(filename).await - } else { - chuncked_static_file_download(filename).await - } - }) - .await + .await?; + + if metadata.len() < 1024*32 { + simple_static_file_download(filename).await + } else { + chuncked_static_file_download(filename).await + } } fn extract_auth_data(headers: &http::HeaderMap) -> (Option, Option) {