aboutsummaryrefslogtreecommitdiff
path: root/src/api/s3/multipart.rs
diff options
context:
space:
mode:
authorAlex <alex@adnab.me>2023-10-24 10:07:16 +0000
committerAlex <alex@adnab.me>2023-10-24 10:07:16 +0000
commit75d5d08ee1f46b238d6efe3f3f39cc6b9a8d3856 (patch)
tree5059701470a55c785d12306574b8041f90d9b59b /src/api/s3/multipart.rs
parenta5e8ffeb63a193e5b0e020e4c014687e57f85c23 (diff)
parentc82d91c6bccf307186332b6c5c6fc0b128b1b2b1 (diff)
downloadgarage-75d5d08ee1f46b238d6efe3f3f39cc6b9a8d3856.tar.gz
garage-75d5d08ee1f46b238d6efe3f3f39cc6b9a8d3856.zip
Merge pull request 'Ensure increasing version timestamps when writing new object versions' (#543) from increasing-timestamps into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/543
Diffstat (limited to 'src/api/s3/multipart.rs')
-rw-r--r--src/api/s3/multipart.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/api/s3/multipart.rs b/src/api/s3/multipart.rs
index 52ea8e78..6b786318 100644
--- a/src/api/s3/multipart.rs
+++ b/src/api/s3/multipart.rs
@@ -9,7 +9,6 @@ use md5::{Digest as Md5Digest, Md5};
use garage_table::*;
use garage_util::async_hash::*;
use garage_util::data::*;
-use garage_util::time::*;
use garage_model::bucket_table::Bucket;
use garage_model::garage::Garage;
@@ -30,10 +29,13 @@ pub async fn handle_create_multipart_upload(
req: &Request<Body>,
bucket_name: &str,
bucket_id: Uuid,
- key: &str,
+ key: &String,
) -> Result<Response<Body>, Error> {
+ let existing_object = garage.object_table.get(&bucket_id, &key).await?;
+
let upload_id = gen_uuid();
- let timestamp = now_msec();
+ let timestamp = next_timestamp(existing_object.as_ref());
+
let headers = get_headers(req.headers())?;
// Create object in object table
@@ -233,7 +235,8 @@ pub async fn handle_complete_multipart_upload(
// Get object and multipart upload
let key = key.to_string();
- let (_, mut object_version, mpu) = get_upload(&garage, &bucket.id, &key, &upload_id).await?;
+ let (object, mut object_version, mpu) =
+ get_upload(&garage, &bucket.id, &key, &upload_id).await?;
if mpu.parts.is_empty() {
return Err(Error::bad_request("No data was uploaded"));
@@ -331,7 +334,7 @@ pub async fn handle_complete_multipart_upload(
// Calculate total size of final object
let total_size = parts.iter().map(|x| x.size.unwrap()).sum();
- if let Err(e) = check_quotas(&garage, bucket, &key, total_size).await {
+ if let Err(e) = check_quotas(&garage, bucket, total_size, Some(&object)).await {
object_version.state = ObjectVersionState::Aborted;
let final_object = Object::new(bucket.id, key.clone(), vec![object_version]);
garage.object_table.insert(&final_object).await?;