reviewed1
All checks were successful
deploy / deploy (push) Successful in 59s

This commit is contained in:
Untone 2024-10-22 13:33:53 +03:00
parent 2762e40409
commit 74a1a4b242

View File

@ -11,14 +11,17 @@ pub async fn serve_file(file_path: &str, state: &AppState) -> Result<HttpRespons
false => file_path, false => file_path,
}; };
let mut parts = filepath.split('/').collect::<Vec<&str>>(); // Explicit type annotation let mut parts = filepath.split('/').collect::<Vec<&str>>(); // Explicit type annotation
let mut file_fullpath = String::new(); let filename = parts.pop().unwrap_or(""); // Explicit type annotation
if let Some(filename) = parts.pop() { let file_fullpath = state.get_path(filename).await?.unwrap_or(String::new());
file_fullpath = state.get_path(filename).await.unwrap().unwrap();
if file_fullpath.is_empty() {
return Err(ErrorInternalServerError("File not found".to_string()));
} }
// Проверяем наличие файла в Storj S3 // Проверяем наличие файла в Storj S3
if !check_file_exists(&state.storj_client, &state.storj_bucket, &file_fullpath).await? { let exists = check_file_exists(&state.storj_client, &state.storj_bucket, &file_fullpath).await?;
return Err(ErrorInternalServerError(format!("File {} not found in Storj", file_fullpath))); if !exists {
return Err(ErrorInternalServerError("File not found in Storj".to_string()));
} }
// Получаем объект из Storj S3 // Получаем объект из Storj S3