Display the error message on failure

This commit is contained in:
Kerollmops
2025-11-13 10:25:48 +01:00
parent ea70a7d1c9
commit 361580f451

View File

@@ -438,7 +438,7 @@ async fn multipart_stream_to_s3(
db_name: String, db_name: String,
reader: std::io::PipeReader, reader: std::io::PipeReader,
) -> Result<(), Error> { ) -> Result<(), Error> {
use std::{collections::VecDeque, os::fd::OwnedFd, path::PathBuf}; use std::{collections::VecDeque, io, os::fd::OwnedFd, path::PathBuf};
use bytes::{Bytes, BytesMut}; use bytes::{Bytes, BytesMut};
use reqwest::{Client, Response}; use reqwest::{Client, Response};
@@ -517,7 +517,6 @@ async fn multipart_stream_to_s3(
while buffer.len() < (s3_multipart_part_size as usize / 2) { while buffer.len() < (s3_multipart_part_size as usize / 2) {
// Wait for the pipe to be readable // Wait for the pipe to be readable
use std::io;
reader.readable().await?; reader.readable().await?;
match reader.try_read_buf(&mut buffer) { match reader.try_read_buf(&mut buffer) {
@@ -580,16 +579,19 @@ async fn multipart_stream_to_s3(
let body = body.clone(); let body = body.clone();
async move { async move {
match client.post(url).body(body).send().await { match client.post(url).body(body).send().await {
Ok(resp) if resp.status().is_client_error() => { Ok(resp) if resp.status().is_client_error() => match resp.error_for_status_ref() {
resp.error_for_status().map_err(backoff::Error::Permanent) Ok(_) => Ok(resp),
} Err(_) => Err(backoff::Error::Permanent(Error::S3Error {
status: resp.status(),
body: resp.text().await.unwrap_or_default(),
})),
},
Ok(resp) => Ok(resp), Ok(resp) => Ok(resp),
Err(e) => Err(backoff::Error::transient(e)), Err(e) => Err(backoff::Error::transient(Error::S3HttpError(e))),
} }
} }
}) })
.await .await?;
.map_err(Error::S3HttpError)?;
let status = resp.status(); let status = resp.status();
let body = resp.text().await.map_err(|e| Error::S3Error { status, body: e.to_string() })?; let body = resp.text().await.map_err(|e| Error::S3Error { status, body: e.to_string() })?;