Merge pull request 'Properly return HTTP 204 when deleting non-existent object (fix #227)' (#384) from deleteobject-204 into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/384
This commit is contained in:
commit
89b8087ba8
@ -64,14 +64,13 @@ pub async fn handle_delete(
|
|||||||
bucket_id: Uuid,
|
bucket_id: Uuid,
|
||||||
key: &str,
|
key: &str,
|
||||||
) -> Result<Response<Body>, Error> {
|
) -> Result<Response<Body>, Error> {
|
||||||
let (_deleted_version, delete_marker_version) =
|
match handle_delete_internal(&garage, bucket_id, key).await {
|
||||||
handle_delete_internal(&garage, bucket_id, key).await?;
|
Ok(_) | Err(Error::NoSuchKey) => Ok(Response::builder()
|
||||||
|
.status(StatusCode::NO_CONTENT)
|
||||||
Ok(Response::builder()
|
.body(Body::from(vec![]))
|
||||||
.header("x-amz-version-id", hex::encode(delete_marker_version))
|
.unwrap()),
|
||||||
.status(StatusCode::NO_CONTENT)
|
Err(e) => Err(e),
|
||||||
.body(Body::from(vec![]))
|
}
|
||||||
.unwrap())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn handle_delete_objects(
|
pub async fn handle_delete_objects(
|
||||||
|
@ -263,4 +263,13 @@ async fn test_deleteobject() {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert!(l.contents.is_none());
|
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();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user