diff options
author | Alex Auvolat <alex@adnab.me> | 2020-04-26 20:39:32 +0000 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-04-26 20:39:32 +0000 |
commit | 81ecc4999e16c58ce6d0e97501f7b6b1497f6cf6 (patch) | |
tree | d22638738b6105ebc8c7eb8fe1d633bf3627b034 /src/core | |
parent | 1999c0ae5152917625558c588e71b27f63950f41 (diff) | |
download | garage-81ecc4999e16c58ce6d0e97501f7b6b1497f6cf6.tar.gz garage-81ecc4999e16c58ce6d0e97501f7b6b1497f6cf6.zip |
Implement multipart uploads
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/object_table.rs | 4 | ||||
-rw-r--r-- | src/core/version_table.rs | 11 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/core/object_table.rs b/src/core/object_table.rs index 04f64fe7..01df70e6 100644 --- a/src/core/object_table.rs +++ b/src/core/object_table.rs @@ -88,6 +88,7 @@ impl ObjectVersionState { #[derive(PartialEq, Clone, Debug, Serialize, Deserialize)] pub enum ObjectVersionData { + Uploading, DeleteMarker, Inline(#[serde(with = "serde_bytes")] Vec<u8>), FirstBlock(Hash), @@ -125,6 +126,9 @@ impl Entry<String, String> for Object { v.size = other_v.size; } v.state = v.state.max(other_v.state); + if v.data == ObjectVersionData::Uploading { + v.data = other_v.data.clone(); + } } Err(i) => { self.versions.insert(i, other_v.clone()); diff --git a/src/core/version_table.rs b/src/core/version_table.rs index cd4448ad..66f737bb 100644 --- a/src/core/version_table.rs +++ b/src/core/version_table.rs @@ -49,7 +49,7 @@ impl Version { } /// Adds a block if it wasn't already present pub fn add_block(&mut self, new: VersionBlock) -> Result<(), ()> { - match self.blocks.binary_search_by(|b| b.offset.cmp(&new.offset)) { + match self.blocks.binary_search_by(|b| b.cmp_key().cmp(&new.cmp_key())) { Err(i) => { self.blocks.insert(i, new); Ok(()) @@ -67,6 +67,13 @@ pub struct VersionBlock { pub part_number: u64, pub offset: u64, pub hash: Hash, + pub size: u64, +} + +impl VersionBlock { + fn cmp_key(&self) -> (u64, u64) { + (self.part_number, self.offset) + } } impl Entry<Hash, EmptyKey> for Version { @@ -83,7 +90,7 @@ impl Entry<Hash, EmptyKey> for Version { self.blocks.clear(); } else if !self.deleted { for bi in other.blocks.iter() { - match self.blocks.binary_search_by(|x| x.offset.cmp(&bi.offset)) { + match self.blocks.binary_search_by(|x| x.cmp_key().cmp(&bi.cmp_key())) { Ok(_) => (), Err(pos) => { self.blocks.insert(pos, bi.clone()); |