aboutsummaryrefslogtreecommitdiff
path: root/src/api/s3_delete.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-04-28 01:05:40 +0200
committerAlex Auvolat <alex@adnab.me>2021-04-28 01:05:40 +0200
commitdcfc32cf85bc6276fdff2492898c1cbb527e9b9d (patch)
tree01ec3f7476733dab8c74ecb1c72b5061f6e5c8e1 /src/api/s3_delete.rs
parent368eb354846790e9fc616d9a26ddc414748d847f (diff)
downloadgarage-dcfc32cf85bc6276fdff2492898c1cbb527e9b9d.tar.gz
garage-dcfc32cf85bc6276fdff2492898c1cbb527e9b9d.zip
Many S3 compatibility improvements:v0.2.1.5
- return XML errors - implement AuthorizationHeaderMalformed error to redirect clients to correct location (used by minio client) - implement GetBucketLocation - fix DeleteObjects XML parsing and response
Diffstat (limited to 'src/api/s3_delete.rs')
-rw-r--r--src/api/s3_delete.rs23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/api/s3_delete.rs b/src/api/s3_delete.rs
index 6abbfc48..05387403 100644
--- a/src/api/s3_delete.rs
+++ b/src/api/s3_delete.rs
@@ -85,11 +85,18 @@ pub async fn handle_delete_objects(
let mut retxml = String::new();
writeln!(&mut retxml, r#"<?xml version="1.0" encoding="UTF-8"?>"#).unwrap();
- writeln!(&mut retxml, "<DeleteObjectsOutput>").unwrap();
+ writeln!(
+ &mut retxml,
+ r#"<DeleteResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">"#
+ )
+ .unwrap();
for obj in cmd.objects.iter() {
match handle_delete_internal(&garage, bucket, &obj.key).await {
Ok((deleted_version, delete_marker_version)) => {
+ if cmd.quiet {
+ continue;
+ }
writeln!(&mut retxml, "\t<Deleted>").unwrap();
writeln!(&mut retxml, "\t\t<Key>{}</Key>", xml_escape(&obj.key)).unwrap();
writeln!(
@@ -121,7 +128,7 @@ pub async fn handle_delete_objects(
}
}
- writeln!(&mut retxml, "</DeleteObjectsOutput>").unwrap();
+ writeln!(&mut retxml, "</DeleteResult>").unwrap();
Ok(Response::builder()
.header("Content-Type", "application/xml")
@@ -129,6 +136,7 @@ pub async fn handle_delete_objects(
}
struct DeleteRequest {
+ quiet: bool,
objects: Vec<DeleteObject>,
}
@@ -137,7 +145,10 @@ struct DeleteObject {
}
fn parse_delete_objects_xml(xml: &roxmltree::Document) -> Option<DeleteRequest> {
- let mut ret = DeleteRequest { objects: vec![] };
+ let mut ret = DeleteRequest {
+ quiet: false,
+ objects: vec![],
+ };
let root = xml.root();
let delete = root.first_child()?;
@@ -153,6 +164,12 @@ fn parse_delete_objects_xml(xml: &roxmltree::Document) -> Option<DeleteRequest>
ret.objects.push(DeleteObject {
key: key_str.to_string(),
});
+ } else if item.has_tag_name("Quiet") {
+ if item.text()? == "true" {
+ ret.quiet = true;
+ } else {
+ ret.quiet = false;
+ }
} else {
return None;
}