aboutsummaryrefslogtreecommitdiff
path: root/src/api/s3_delete.rs
diff options
context:
space:
mode:
authorQuentin <quentin@dufour.io>2020-11-11 16:41:57 +0100
committerQuentin <quentin@dufour.io>2020-11-11 16:41:57 +0100
commitd9309ec3e7d71785716e0ccc3b29fba073841062 (patch)
treedc75f03d79f6269904f5ac0f8fb531c33c6c0ae4 /src/api/s3_delete.rs
parent758e9e4e0c1304e2e9ac1a667840b63b880d1eca (diff)
parentb00e29f931dcfe79b766e2c5b2c9ddb5f6a2f200 (diff)
downloadgarage-feature/refactor-s3-2.tar.gz
garage-feature/refactor-s3-2.zip
Merge branch 'master' into feature/refactor-s3-2feature/refactor-s3-2
Diffstat (limited to 'src/api/s3_delete.rs')
-rw-r--r--src/api/s3_delete.rs21
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));
}