diff options
Diffstat (limited to 'src/api/s3_delete.rs')
-rw-r--r-- | src/api/s3_delete.rs | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/src/api/s3_delete.rs b/src/api/s3_delete.rs index 33e47c17..f46bfcfe 100644 --- a/src/api/s3_delete.rs +++ b/src/api/s3_delete.rs @@ -16,17 +16,11 @@ async fn handle_delete_internal( bucket: &str, key: &str, ) -> Result<(UUID, UUID), Error> { - let object = match garage + let object = garage .object_table .get(&bucket.to_string(), &key.to_string()) .await? - { - None => { - // No need to delete - return Err(Error::NotFound); - } - Some(o) => o, - }; + .ok_or(Error::NotFound)?; // No need to delete let interesting_versions = object.versions().iter().filter(|v| match v.state { ObjectVersionState::Aborted => false, @@ -43,10 +37,7 @@ async fn handle_delete_internal( timestamp = std::cmp::max(timestamp, v.timestamp + 1); } - let deleted_version = match must_delete { - None => return Err(Error::NotFound), - Some(v) => v, - }; + let deleted_version = must_delete.ok_or(Error::NotFound)?; let version_uuid = gen_uuid(); @@ -142,10 +133,8 @@ fn parse_delete_objects_xml(xml: &roxmltree::Document) -> Result<DeleteRequest, let mut ret = DeleteRequest { objects: vec![] }; let root = xml.root(); - let delete = match root.first_child() { - Some(del) => del, - None => return Err(format!("Delete tag not found")), - }; + let delete = root.first_child().ok_or(format!("Delete tag not found"))?; + if !delete.has_tag_name("Delete") { return Err(format!("Invalid root tag: {:?}", root)); } |