diff --git a/libimagstore/src/hook/accessor.rs b/libimagstore/src/hook/accessor.rs index b3c1f0f1..a8dcb45c 100644 --- a/libimagstore/src/hook/accessor.rs +++ b/libimagstore/src/hook/accessor.rs @@ -1,5 +1,10 @@ use hook::result::HookResult; use store::FileLockEntry; +use storeid::StoreId; + +pub trait StoreIdAccessor : Send + Sync { + fn access(&self, &StoreId) -> HookResult<()>; +} pub trait MutableHookDataAccessor : Send + Sync { fn access_mut(&self, &mut FileLockEntry) -> HookResult<()>; @@ -10,6 +15,7 @@ pub trait NonMutableHookDataAccessor : Send + Sync { } pub enum HookDataAccessor { + StoreIdAccess(Box), MutableAccess(Box), NonMutableAccess(Box), } diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index 3090ad6a..c07c30d0 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -498,19 +498,25 @@ impl Store { match accessor.deref() { &HDA::MutableAccess(ref accessor) => { match acc { - Ok(mut fle) => accessor.access_mut(&mut fle).and(Ok(fle)), - Err(e) => Err(e), + Ok(mut fle) => accessor + .access_mut(&mut fle) + .and(Ok(fle)) + .map_err(|e| SE::new(SEK::HookExecutionError, Some(Box::new(e)))), + Err(e) => Err(SE::new(SEK::HookExecutionError, Some(Box::new(e)))), } }, &HDA::NonMutableAccess(ref accessor) => { match acc { - Ok(mut fle) => accessor.access(&fle).and(Ok(fle)), - Err(e) => Err(e), + Ok(mut fle) => accessor + .access(&fle) + .and(Ok(fle)) + .map_err(|e| SE::new(SEK::HookExecutionError, Some(Box::new(e)))), + Err(e) => Err(SE::new(SEK::HookExecutionError, Some(Box::new(e)))), } }, + _ => Err(StoreError::new(StoreErrorKind::HookExecutionError, None)), } }) - .map_err(|e| SE::new(SEK::HookExecutionError, Some(Box::new(e)))) } }