aboutsummaryrefslogtreecommitdiff
path: root/src/object_table.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-04-09 20:58:39 +0200
committerAlex Auvolat <alex@adnab.me>2020-04-09 20:58:39 +0200
commita3eb88e6013e70238e7ddd66b4644f138b3d1b93 (patch)
tree850f76d80d1a609d699040e651e569645604e6ab /src/object_table.rs
parent1d786c2c663ac6f6e3e3ef52accd6e9eca049988 (diff)
downloadgarage-a3eb88e6013e70238e7ddd66b4644f138b3d1b93.tar.gz
garage-a3eb88e6013e70238e7ddd66b4644f138b3d1b93.zip
Locally, transactions
Diffstat (limited to 'src/object_table.rs')
-rw-r--r--src/object_table.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/object_table.rs b/src/object_table.rs
index 626c00b2..092dddf8 100644
--- a/src/object_table.rs
+++ b/src/object_table.rs
@@ -47,20 +47,25 @@ impl Entry<String, String> for Object {
&self.key
}
- fn merge(&mut self, other: &Self) {
+ fn merge(&mut self, other: &Self) -> bool {
+ let mut has_change = false;
+
for other_v in other.versions.iter() {
match self.versions.binary_search_by(|v| (v.timestamp, &v.uuid).cmp(&(other_v.timestamp, &other_v.uuid))) {
Ok(i) => {
let mut v = &mut self.versions[i];
if other_v.size > v.size {
v.size = other_v.size;
+ has_change = true;
}
- if other_v.is_complete {
+ if other_v.is_complete && !v.is_complete {
v.is_complete = true;
+ has_change = true;
}
}
Err(i) => {
self.versions.insert(i, other_v.clone());
+ has_change = true;
}
}
}
@@ -73,6 +78,8 @@ impl Entry<String, String> for Object {
if let Some(last_vi) = last_complete {
self.versions = self.versions.drain(last_vi..).collect::<Vec<_>>();
}
+
+ has_change
}
}