diff options
author | Alex Auvolat <alex@adnab.me> | 2020-04-17 14:49:10 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-04-17 14:49:10 +0200 |
commit | 867646093b24a9bb7e4b24a7f2248615c6e03fde (patch) | |
tree | 3e4c371c507112eb7f22d319303294ea3afca732 /src/block_ref_table.rs | |
parent | 6ce14e2c9eb1ba81add3f61377a5a83854880b42 (diff) | |
download | garage-867646093b24a9bb7e4b24a7f2248615c6e03fde.tar.gz garage-867646093b24a9bb7e4b24a7f2248615c6e03fde.zip |
Table range deletion
Diffstat (limited to 'src/block_ref_table.rs')
-rw-r--r-- | src/block_ref_table.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/block_ref_table.rs b/src/block_ref_table.rs index 4364b646..21fe4658 100644 --- a/src/block_ref_table.rs +++ b/src/block_ref_table.rs @@ -45,20 +45,21 @@ impl TableSchema for BlockRefTable { type S = UUID; type E = BlockRef; - async fn updated(&self, old: Option<Self::E>, new: Self::E) { - let was_before = old.map(|x| !x.deleted).unwrap_or(false); - let is_after = !new.deleted; + async fn updated(&self, old: Option<Self::E>, new: Option<Self::E>) { + let block = &old.as_ref().or(new.as_ref()).unwrap().block; + let was_before = old.as_ref().map(|x| !x.deleted).unwrap_or(false); + let is_after = new.as_ref().map(|x| !x.deleted).unwrap_or(false); if is_after && !was_before { - if let Err(e) = self.block_manager.block_incref(&new.block) { - eprintln!("Failed to incref block {:?}: {}", &new.block, e); + if let Err(e) = self.block_manager.block_incref(block) { + eprintln!("Failed to incref block {:?}: {}", block, e); } } if was_before && !is_after { if let Err(e) = self .block_manager - .block_decref(&new.block, &self.background) + .block_decref(block, &self.background) { - eprintln!("Failed to decref block {:?}: {}", &new.block, e); + eprintln!("Failed to decref block {:?}: {}", block, e); } } } |