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