From 867646093b24a9bb7e4b24a7f2248615c6e03fde Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 17 Apr 2020 14:49:10 +0200 Subject: Table range deletion --- src/block_ref_table.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/block_ref_table.rs') 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, 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, new: Option) { + 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); } } } -- cgit v1.2.3