This commit is contained in:
@@ -92,17 +92,17 @@ impl AppState {
|
||||
let mut redis = self.redis.clone();
|
||||
|
||||
// Запрашиваем список файлов из Storj S3
|
||||
let filekeyed_list = get_s3_filelist(&self.storj_client, &self.storj_bucket).await;
|
||||
let filelist = get_s3_filelist(&self.storj_client, &self.storj_bucket).await;
|
||||
|
||||
for [filekey, filepath] in filekeyed_list.clone() {
|
||||
for [filename, filepath] in filelist.clone() {
|
||||
// Сохраняем список файлов в Redis, используя HSET для каждого файла
|
||||
let _: () = redis
|
||||
.hset(PATH_MAPPING_KEY, filekey.clone(), filepath)
|
||||
.hset(PATH_MAPPING_KEY, filename.clone(), filepath)
|
||||
.await
|
||||
.expect(&format!("Failed to cache file {} in Redis", filekey));
|
||||
.expect(&format!("Failed to cache file {} in Redis", filename));
|
||||
}
|
||||
|
||||
info!("cached {} files", filekeyed_list.len());
|
||||
info!("cached {} files", filelist.len());
|
||||
}
|
||||
|
||||
/// Получает кэшированный список файлов из Redis.
|
||||
@@ -117,10 +117,10 @@ impl AppState {
|
||||
}
|
||||
|
||||
/// Получает путь в Storj из ключа (имени файла) в Redis.
|
||||
pub async fn get_path(&self, file_key: &str) -> Result<Option<String>, actix_web::Error> {
|
||||
pub async fn get_path(&self, filename: &str) -> Result<Option<String>, actix_web::Error> {
|
||||
let mut redis = self.redis.clone();
|
||||
let new_path: Option<String> = redis
|
||||
.hget(PATH_MAPPING_KEY, file_key)
|
||||
.hget(PATH_MAPPING_KEY, filename)
|
||||
.await
|
||||
.map_err(|_| ErrorInternalServerError("Failed to get path mapping from Redis"))?;
|
||||
Ok(new_path)
|
||||
|
Reference in New Issue
Block a user