diff options
author | Alex Auvolat <alex@adnab.me> | 2022-09-14 17:07:55 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-09-14 17:07:55 +0200 |
commit | 76f42a1a2b5cf088968a0730cf6de31b75f7a055 (patch) | |
tree | 1f9ad320ae90c62da74a311b86cc814d62f8b072 | |
parent | 82600acf776acecfa73fbf23d4c7107eaae81e09 (diff) | |
download | garage-deleteobject-204.tar.gz garage-deleteobject-204.zip |
Properly return HTTP 204 when deleting non-existent object (fix #227)deleteobject-204
-rw-r--r-- | src/api/s3/delete.rs | 15 | ||||
-rw-r--r-- | src/garage/tests/s3/objects.rs | 9 |
2 files changed, 16 insertions, 8 deletions
diff --git a/src/api/s3/delete.rs b/src/api/s3/delete.rs index 5065b285..b337155f 100644 --- a/src/api/s3/delete.rs +++ b/src/api/s3/delete.rs @@ -64,14 +64,13 @@ pub async fn handle_delete( bucket_id: Uuid, key: &str, ) -> Result<Response<Body>, Error> { - let (_deleted_version, delete_marker_version) = - handle_delete_internal(&garage, bucket_id, key).await?; - - Ok(Response::builder() - .header("x-amz-version-id", hex::encode(delete_marker_version)) - .status(StatusCode::NO_CONTENT) - .body(Body::from(vec![])) - .unwrap()) + match handle_delete_internal(&garage, bucket_id, key).await { + Ok(_) | Err(Error::NoSuchKey) => Ok(Response::builder() + .status(StatusCode::NO_CONTENT) + .body(Body::from(vec![])) + .unwrap()), + Err(e) => Err(e), + } } pub async fn handle_delete_objects( diff --git a/src/garage/tests/s3/objects.rs b/src/garage/tests/s3/objects.rs index e1175b81..65f9e867 100644 --- a/src/garage/tests/s3/objects.rs +++ b/src/garage/tests/s3/objects.rs @@ -263,4 +263,13 @@ async fn test_deleteobject() { .unwrap(); assert!(l.contents.is_none()); + + // Deleting a non-existing object shouldn't be a problem + ctx.client + .delete_object() + .bucket(&bucket) + .key("l-0") + .send() + .await + .unwrap(); } |