aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2024-02-23 18:28:05 +0100
committerAlex Auvolat <alex@adnab.me>2024-02-23 18:28:05 +0100
commit3692af7052f5efbb00b37d363b1c8952c0815519 (patch)
tree132af9334ad0f930ec5fc852811fe9abc0768911 /src
parent916c67ccf4c9d31c14088f2d775e15c64750458f (diff)
parente399b60e255f14585a58765693b000db69aed09f (diff)
downloadgarage-3692af7052f5efbb00b37d363b1c8952c0815519.tar.gz
garage-3692af7052f5efbb00b37d363b1c8952c0815519.zip
Merge branch 'main' into next-0.10
Diffstat (limited to 'src')
-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 {