aboutsummaryrefslogtreecommitdiff
path: root/src/version_table.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-04-11 19:43:29 +0200
committerAlex Auvolat <alex@adnab.me>2020-04-11 19:43:29 +0200
commitdcf58499a4f529e1033de65b4fca8d45458d60d2 (patch)
tree45cae7a9a1ee240c9e95c9e6591b96ebe679b047 /src/version_table.rs
parent53289b69e5037700689665b4edf20f2382ff15f6 (diff)
downloadgarage-dcf58499a4f529e1033de65b4fca8d45458d60d2.tar.gz
garage-dcf58499a4f529e1033de65b4fca8d45458d60d2.zip
table::insert_many, version_table::updated
Diffstat (limited to 'src/version_table.rs')
-rw-r--r--src/version_table.rs21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/version_table.rs b/src/version_table.rs
index d037d344..d9d2b675 100644
--- a/src/version_table.rs
+++ b/src/version_table.rs
@@ -63,8 +63,23 @@ impl TableFormat for VersionTable {
type S = EmptySortKey;
type E = Version;
- async fn updated(&self, old: Option<&Self::E>, new: &Self::E) {
- //unimplemented!()
- // TODO
+ async fn updated(&self, old: Option<Self::E>, new: Self::E) {
+ let garage = self.garage.read().await.as_ref().cloned().unwrap();
+ garage.clone().background.spawn(async move {
+ // Propagate deletion of version blocks
+ if let Some(old_v) = old {
+ if new.deleted && !old_v.deleted {
+ let deleted_block_refs = old_v.blocks.iter()
+ .map(|vb| BlockRef{
+ block: vb.hash.clone(),
+ version: old_v.uuid.clone(),
+ deleted: true,
+ })
+ .collect::<Vec<_>>();
+ garage.block_ref_table.insert_many(&deleted_block_refs[..]).await?;
+ }
+ }
+ Ok(())
+ });
}
}