Adapt S3 API code to use new multipart upload models

- Create and PutPart
- completemultipartupload
- upload part copy
- list_parts
This commit is contained in:
Alex Auvolat
2023-05-03 12:02:59 +02:00
parent 38d6ac4295
commit 82e75c0e29
9 changed files with 610 additions and 546 deletions
+15
View File
@@ -3,6 +3,7 @@ use std::sync::Arc;
use garage_db as db;
use garage_util::data::*;
use garage_util::time::*;
use garage_table::crdt::*;
use garage_table::replication::TableShardedReplication;
@@ -94,6 +95,20 @@ impl MultipartUpload {
key,
}
}
pub fn next_timestamp(&self, part_number: u64) -> u64 {
std::cmp::max(
now_msec(),
1 + self
.parts
.items()
.iter()
.filter(|(x, _)| x.part_number == part_number)
.map(|(x, _)| x.timestamp)
.max()
.unwrap_or(0),
)
}
}
impl Entry<Uuid, EmptyKey> for MultipartUpload {
+11
View File
@@ -3,6 +3,7 @@ use std::sync::Arc;
use garage_db as db;
use garage_util::data::*;
use garage_util::error::*;
use garage_table::crdt::*;
use garage_table::replication::TableShardedReplication;
@@ -188,6 +189,16 @@ impl Version {
.binary_search_by(|(k, _)| k.part_number.cmp(&part_number))
.is_ok()
}
pub fn n_parts(&self) -> Result<u64, Error> {
Ok(self
.blocks
.items()
.last()
.ok_or_message("version has no parts")?
.0
.part_number)
}
}
impl Ord for VersionBlockKey {