faster-static-serve

This commit is contained in:
2025-09-30 20:02:39 +03:00
parent 71c9e5df1b
commit 315c7cd522
2 changed files with 7 additions and 23 deletions

View File

@@ -9,7 +9,7 @@ use crate::app_state::AppState;
use crate::s3_utils::{check_file_exists, load_file_from_s3};
use crate::thumbnail::{
cache_thumbnail_to_storj, generate_webp_thumbnail, is_image_file,
load_cached_thumbnail_from_storj, parse_file_path, thumbnail_exists_in_storj,
load_cached_thumbnail_from_storj, parse_file_path
};
/// Функция для обслуживания файла по заданному пути с поддержкой thumbnail генерации.
@@ -78,27 +78,7 @@ pub async fn serve_file(
}
}
// Проверяем состояние Storj кэша для диагностики
let storj_cache_exists = thumbnail_exists_in_storj(
&state.storj_client,
&state.bucket,
&base_filename,
requested_width,
None,
)
.await;
if storj_cache_exists {
warn!(
"Thumbnail exists in Storj but failed to load for {}",
base_filename
);
} else {
info!(
"No thumbnail in Storj cache for {}, will generate new",
base_filename
);
}
// NOTE: Thumbnail не найден в кэше - генерируем новый (без лишних проверок существования)
// Генерируем новый thumbnail
match generate_webp_thumbnail(&filedata, requested_width, None) {

View File

@@ -270,7 +270,11 @@ pub async fn load_cached_thumbnail_from_storj(
}
},
Err(e) => {
warn!("Failed to load cached thumbnail from Storj: {}", e);
// NOTE: Не логируем ошибку если thumbnail просто не существует (нормальное поведение)
let error_msg = e.to_string();
if !error_msg.contains("NoSuchKey") && !error_msg.contains("Not Found") {
warn!("Failed to load cached thumbnail from Storj: {}", e);
}
None
}
}