diff options
author | Alex <alex@adnab.me> | 2020-11-11 16:38:56 +0100 |
---|---|---|
committer | Alex <alex@adnab.me> | 2020-11-11 16:38:56 +0100 |
commit | b00e29f931dcfe79b766e2c5b2c9ddb5f6a2f200 (patch) | |
tree | e0e8e02ddaed445ec331342c2b4328829accd889 /src/api/s3_delete.rs | |
parent | 045009da9b7ac4198574bd5aa256c11cfe4ae469 (diff) | |
parent | 7d7b9e95a9b7fe71e7bb42b08a22698475a9c78c (diff) | |
download | garage-b00e29f931dcfe79b766e2c5b2c9ddb5f6a2f200.tar.gz garage-b00e29f931dcfe79b766e2c5b2c9ddb5f6a2f200.zip |
Merge pull request 'Option Type: replace pattern matching by the corresponding syntaxic sugar' (#13) from feature/syntaxic-sugar into master
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/13
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)); } |