Fix S3 ListObjects result and replace println!s by debug!s

This commit is contained in:
Alex Auvolat 2021-01-16 16:05:54 +01:00
parent 6a5add3386
commit 36814be447
3 changed files with 6 additions and 6 deletions

View file

@ -10,7 +10,7 @@ PATH="${GARAGE_DEBUG}:${GARAGE_RELEASE}:$PATH"
FANCYCOLORS=("41m" "42m" "44m" "45m" "100m" "104m") FANCYCOLORS=("41m" "42m" "44m" "45m" "100m" "104m")
export RUST_BACKTRACE=1 export RUST_BACKTRACE=1
export RUST_LOG=garage=info export RUST_LOG=garage=info,garage_api=debug
MAIN_LABEL="\e[${FANCYCOLORS[0]}[main]\e[49m" MAIN_LABEL="\e[${FANCYCOLORS[0]}[main]\e[49m"
WHICH_GARAGE=$(which garage || exit 1) WHICH_GARAGE=$(which garage || exit 1)

View file

@ -173,7 +173,7 @@ async fn handler_inner(garage: Arc<Garage>, req: Request<Body>) -> Result<Respon
&Method::PUT => { &Method::PUT => {
// CreateBucket // CreateBucket
// If we're here, the bucket already exists, so just answer ok // If we're here, the bucket already exists, so just answer ok
println!( debug!(
"Body: {}", "Body: {}",
std::str::from_utf8(&hyper::body::to_bytes(req.into_body()).await?) std::str::from_utf8(&hyper::body::to_bytes(req.into_body()).await?)
.unwrap_or("<invalid utf8>") .unwrap_or("<invalid utf8>")
@ -229,7 +229,7 @@ async fn handler_inner(garage: Arc<Garage>, req: Request<Body>) -> Result<Respon
// DeleteObjects // DeleteObjects
Ok(handle_delete_objects(garage, bucket, req).await?) Ok(handle_delete_objects(garage, bucket, req).await?)
} else { } else {
println!( debug!(
"Body: {}", "Body: {}",
std::str::from_utf8(&hyper::body::to_bytes(req.into_body()).await?) std::str::from_utf8(&hyper::body::to_bytes(req.into_body()).await?)
.unwrap_or("<invalid utf8>") .unwrap_or("<invalid utf8>")

View file

@ -150,8 +150,8 @@ pub async fn handle_list(
writeln!(&mut xml, "\t</Contents>").unwrap(); writeln!(&mut xml, "\t</Contents>").unwrap();
} }
if result_common_prefixes.len() > 0 { if result_common_prefixes.len() > 0 {
writeln!(&mut xml, "\t<CommonPrefixes>").unwrap();
for pfx in result_common_prefixes.iter() { for pfx in result_common_prefixes.iter() {
writeln!(&mut xml, "\t<CommonPrefixes>").unwrap();
writeln!( writeln!(
&mut xml, &mut xml,
"\t\t<Prefix>{}</Prefix>", "\t\t<Prefix>{}</Prefix>",
@ -159,11 +159,11 @@ pub async fn handle_list(
//xml_encode_key(pfx, urlencode_resp) //xml_encode_key(pfx, urlencode_resp)
) )
.unwrap(); .unwrap();
}
writeln!(&mut xml, "\t</CommonPrefixes>").unwrap(); writeln!(&mut xml, "\t</CommonPrefixes>").unwrap();
} }
}
writeln!(&mut xml, "</ListBucketResult>").unwrap(); writeln!(&mut xml, "</ListBucketResult>").unwrap();
println!("{}", xml); debug!("{}", xml);
Ok(Response::new(Body::from(xml.into_bytes()))) Ok(Response::new(Body::from(xml.into_bytes())))
} }