aboutsummaryrefslogtreecommitdiff
path: root/src/api/s3
diff options
context:
space:
mode:
authorAlex <alex@adnab.me>2024-02-23 17:26:53 +0000
committerAlex <alex@adnab.me>2024-02-23 17:26:53 +0000
commite399b60e255f14585a58765693b000db69aed09f (patch)
tree1c9ea24fc5d1b83e07330b5dce49964efd9f503a /src/api/s3
parent61758ce0f91b930542bd2ee3c72735000cc12e75 (diff)
parentd640102b76b7d2084c70a3024ac9d55615016620 (diff)
downloadgarage-e399b60e255f14585a58765693b000db69aed09f.tar.gz
garage-e399b60e255f14585a58765693b000db69aed09f.zip
Merge pull request 'GetObject: split out handle_get_full (small refactoring)' (#732) from split_getobject into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/732
Diffstat (limited to 'src/api/s3')
-rw-r--r--src/api/s3/get.rs34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/api/s3/get.rs b/src/api/s3/get.rs
index efb8d4ab..0d18e775 100644
--- a/src/api/s3/get.rs
+++ b/src/api/s3/get.rs
@@ -253,16 +253,12 @@ pub async fn handle_get(
}
match (part_number, parse_range_header(req, last_v_meta.size)?) {
- (Some(_), Some(_)) => {
- return Err(Error::bad_request(
- "Cannot specify both partNumber and Range header",
- ));
- }
- (Some(pn), None) => {
- return handle_get_part(garage, last_v, last_v_data, last_v_meta, pn).await;
- }
+ (Some(_), Some(_)) => Err(Error::bad_request(
+ "Cannot specify both partNumber and Range header",
+ )),
+ (Some(pn), None) => handle_get_part(garage, last_v, last_v_data, last_v_meta, pn).await,
(None, Some(range)) => {
- return handle_get_range(
+ handle_get_range(
garage,
last_v,
last_v_data,
@@ -270,17 +266,25 @@ pub async fn handle_get(
range.start,
range.start + range.length,
)
- .await;
+ .await
}
- (None, None) => (),
+ (None, None) => handle_get_full(garage, last_v, last_v_data, last_v_meta, overrides).await,
}
+}
- let mut resp_builder = object_headers(last_v, last_v_meta)
- .header(CONTENT_LENGTH, format!("{}", last_v_meta.size))
+async fn handle_get_full(
+ garage: Arc<Garage>,
+ version: &ObjectVersion,
+ version_data: &ObjectVersionData,
+ version_meta: &ObjectVersionMeta,
+ overrides: GetObjectOverrides,
+) -> Result<Response<ResBody>, Error> {
+ let mut resp_builder = object_headers(version, version_meta)
+ .header(CONTENT_LENGTH, format!("{}", version_meta.size))
.status(StatusCode::OK);
getobject_override_headers(overrides, &mut resp_builder)?;
- match &last_v_data {
+ match &version_data {
ObjectVersionData::DeleteMarker => unreachable!(),
ObjectVersionData::Inline(_, bytes) => {
Ok(resp_builder.body(bytes_body(bytes.to_vec().into()))?)
@@ -290,7 +294,7 @@ pub async fn handle_get(
let order_stream = OrderTag::stream();
let first_block_hash = *first_block_hash;
- let version_uuid = last_v.uuid;
+ let version_uuid = version.uuid;
tokio::spawn(async move {
match async {