handlers-refactored
Some checks failed
deploy / deploy (push) Failing after 4m4s

This commit is contained in:
2024-10-22 00:36:42 +03:00
parent 4a1f985cce
commit 9fcce86075
9 changed files with 245 additions and 232 deletions

View File

@@ -46,7 +46,7 @@ impl AppState {
env::var("AWS_END_POINT").unwrap_or_else(|_| "https://s3.amazonaws.com".to_string());
let aws_bucket = env::var("AWS_BUCKET_NAME").unwrap_or_else(|_| "discours-io".to_string());
// Конфигурируем клиент S3 для Storj
// Конфигу<EFBFBD><EFBFBD>ируем клиент S3 для Storj
let storj_config = aws_config::defaults(BehaviorVersion::latest())
.region("eu-west-1")
.endpoint_url(s3_endpoint)
@@ -166,10 +166,10 @@ impl AppState {
}
/// Получает путь в хранилище из ключа (имени файла) в Redis.
pub async fn get_path(&self, filename_with_extension: &str) -> Result<Option<String>, actix_web::Error> {
pub async fn get_path(&self, file_key: &str) -> Result<Option<String>, actix_web::Error> {
let mut redis = self.redis.clone();
let new_path: Option<String> = redis
.hget(PATH_MAPPING_KEY, filename_with_extension)
.hget(PATH_MAPPING_KEY, file_key)
.await
.map_err(|_| ErrorInternalServerError("Failed to get path mapping from Redis"))?;
Ok(new_path)
@@ -199,8 +199,7 @@ impl AppState {
eprint!("[ERROR] empty filename: {}", key);
} else {
// Проверяем, существует ли файл на Storj S3
match check_file_exists(&self.s3_client, &self.s3_bucket, &filename_with_extension)
.await
match check_file_exists(&self.s3_client, &self.s3_bucket, &key).await
{
Ok(false) => {
// Сохраняем маппинг пути