From 09acddaef9359840dd0a0ff75e5e9619b574f9e9 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 16 Feb 2016 22:52:47 +0100 Subject: [PATCH] Implement: execute_pre_delete_hooks() --- libimagstore/src/store.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index 0153c9e1..665563da 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -462,7 +462,12 @@ impl Store { } pub fn execute_pre_delete_hooks(&self, id: &StoreId) -> Result<()> { - unimplemented!() + let guard = self.pre_delete_hooks.deref().lock(); + if guard.is_err() { return Err(StoreError::new(StoreErrorKind::PreHookExecuteError, None)) } + + guard.unwrap().deref().iter() + .fold(Ok(()), |acc, hook| acc.and_then(|_| hook.pre_delete(id))) + .map_err(|e| StoreError::new(StoreErrorKind::PreHookExecuteError, Some(Box::new(e)))) } pub fn execute_post_delete_hooks(&self, id: &StoreId) -> Result<()> {