diff options
author | Alex Auvolat <alex@adnab.me> | 2020-04-11 19:43:29 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-04-11 19:43:29 +0200 |
commit | dcf58499a4f529e1033de65b4fca8d45458d60d2 (patch) | |
tree | 45cae7a9a1ee240c9e95c9e6591b96ebe679b047 /src/version_table.rs | |
parent | 53289b69e5037700689665b4edf20f2382ff15f6 (diff) | |
download | garage-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.rs | 21 |
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(()) + }); } } |