This commit is contained in:
parent
705f4c55d0
commit
97911e034a
|
@ -96,11 +96,13 @@ impl AppState {
|
||||||
let filelist = get_s3_filelist(&self.storj_client, &self.storj_bucket).await;
|
let filelist = get_s3_filelist(&self.storj_client, &self.storj_bucket).await;
|
||||||
|
|
||||||
for [filename, filepath] in filelist.clone() {
|
for [filename, filepath] in filelist.clone() {
|
||||||
|
if !filepath.starts_with("/development") {
|
||||||
// Сохраняем список файлов в Redis, используя HSET для каждого файла
|
// Сохраняем список файлов в Redis, используя HSET для каждого файла
|
||||||
let _: () = redis
|
let _: () = redis
|
||||||
.hset(PATH_MAPPING_KEY, filename.clone(), filepath)
|
.hset(PATH_MAPPING_KEY, filename.clone(), filepath)
|
||||||
.await
|
.await
|
||||||
.expect(&format!("Failed to cache file {} in Redis", filename));
|
.expect(&format!("Failed to cache file {} in Redis", filename));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("cached {} files", filelist.len());
|
info!("cached {} files", filelist.len());
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub async fn serve_file(filepath: &str, state: &AppState) -> Result<HttpResponse
|
||||||
// Проверяем наличие файла в Storj S3
|
// Проверяем наличие файла в Storj S3
|
||||||
let exists = check_file_exists(&state.storj_client, &state.storj_bucket, &filepath).await?;
|
let exists = check_file_exists(&state.storj_client, &state.storj_bucket, &filepath).await?;
|
||||||
if !exists {
|
if !exists {
|
||||||
return Err(ErrorInternalServerError("File not found in Storj".to_string()));
|
return Err(ErrorInternalServerError(format!("File {} not found in Storj", filepath)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Получаем объект из Storj S3
|
// Получаем объект из Storj S3
|
||||||
|
|
Loading…
Reference in New Issue
Block a user