prodfix
Some checks failed
deploy / deploy (push) Failing after 6s

This commit is contained in:
Untone 2024-11-11 14:11:11 +03:00
parent 5b7d84de03
commit bdda6b6341

View File

@ -112,30 +112,41 @@ pub async fn proxy_handler(
} else {
warn!("Attempting to load from AWS - bucket: {}, path: {}", state.bucket, stored_path);
return match load_file_from_s3(&state.aws_client, &state.bucket, &stored_path).await {
Ok(filedata) => {
warn!("Successfully loaded file from AWS, size: {} bytes", filedata.len());
warn!("Attempting to upload to Storj with key: {}", filekey);
let aws_paths = vec![
stored_path.clone(),
format!("production/{}", stored_path)
];
if let Err(e) = upload_to_s3(
&state.storj_client,
&state.bucket,
&filekey,
filedata.clone(),
content_type,
).await {
error!("Failed to upload to Storj: {} - Error: {}", filekey, e);
} else {
warn!("Successfully uploaded to Storj: {}", filekey);
for path in aws_paths {
warn!("Trying AWS path: {}", path);
match load_file_from_s3(&state.aws_client, &state.bucket, &path).await {
Ok(filedata) => {
warn!("Successfully loaded file from AWS, size: {} bytes", filedata.len());
warn!("Attempting to upload to Storj with key: {}", filekey);
if let Err(e) = upload_to_s3(
&state.storj_client,
&state.bucket,
&filekey,
filedata.clone(),
content_type,
).await {
error!("Failed to upload to Storj: {} - Error: {}", filekey, e);
} else {
warn!("Successfully uploaded to Storj: {}", filekey);
}
return Ok(HttpResponse::Ok().content_type(content_type).body(filedata));
}
Err(err) => {
warn!("Failed to load from AWS path {}: {:?}", path, err);
continue;
}
}
}
Ok(HttpResponse::Ok().content_type(content_type).body(filedata))
}
Err(err) => {
error!("Failed to load from AWS: {} - Full error: {:?}", stored_path, err);
Err(ErrorInternalServerError(err))
}
};
error!("Failed to load from any AWS path for: {}", stored_path);
Err(ErrorInternalServerError("Failed to load file from AWS"))
}
}
Ok(None) => {