From 5aa663987b95b5d9ed9a565b906e44c349ed6e42 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 16 Feb 2016 22:52:12 +0100 Subject: [PATCH] Implement: execute_pre_update_hooks() --- libimagstore/src/store.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index d02de597..0153c9e1 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -448,8 +448,13 @@ impl Store { unimplemented!() } - pub fn execute_pre_update_hooks(&self, id: &FileLockEntry) -> Result<()> { - unimplemented!() + pub fn execute_pre_update_hooks(&self, fle: &FileLockEntry) -> Result<()> { + let guard = self.pre_update_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_update(fle))) + .map_err(|e| StoreError::new(StoreErrorKind::PreHookExecuteError, Some(Box::new(e)))) } pub fn execute_post_update_hooks(&self, id: &FileLockEntry) -> Result<()> {