Display the error message on failure

This commit is contained in:
Kerollmops
2025-11-13 10:25:48 +01:00
parent 15321ce924
commit ad56e91325

View File

@@ -438,6 +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::io;
use std::{os::fd::OwnedFd, path::PathBuf}; use std::{os::fd::OwnedFd, path::PathBuf};
use bytes::BytesMut; use bytes::BytesMut;
@@ -527,8 +528,6 @@ async fn multipart_stream_to_s3(
// we can continue and send the buffer/part // we can continue and send the buffer/part
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) {
@@ -604,16 +603,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() })?;