From c99f55c4204c81f1a8c368e24b434e02a676a96d Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 25 Jan 2022 12:25:29 +0100 Subject: Add restriction on part ordering in CompleteMultipartUpload --- src/api/s3_put.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/api') diff --git a/src/api/s3_put.rs b/src/api/s3_put.rs index f52080a6..a6863cd3 100644 --- a/src/api/s3_put.rs +++ b/src/api/s3_put.rs @@ -559,6 +559,17 @@ pub async fn handle_complete_multipart_upload( return Err(Error::InvalidPartOrder); } + // Garage-specific restriction, see #204: part numbers must be + // consecutive starting at 1 + if body_list_of_parts[0].part_number != 1 + || !body_list_of_parts + .iter() + .zip(body_list_of_parts.iter().skip(1)) + .all(|(p1, p2)| p1.part_number + 1 == p2.part_number) + { + return Err(Error::NotImplemented("Garage does not support completing a Multipart upload with non-consecutive part numbers. This is a restriction of Garage's data model, which might be fixed in a future release. See issue #204 for more information on this topic.".into())); + } + // Check that the list of parts they gave us corresponds to the parts we have here debug!("Expected parts from request: {:?}", body_list_of_parts); debug!("Parts stored in version: {:?}", version.parts_etags.items()); -- cgit v1.2.3