From f46d4f4dfd489c86e9814ff41aa955956e672947 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 25 Aug 2016 19:26:59 +0200 Subject: [PATCH] Fix libimagstorestdhook::{flock, linkverify}::* for new StoreId interface --- libimagstorestdhook/src/flock.rs | 24 +++++++++--------------- libimagstorestdhook/src/linkverify.rs | 3 +-- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/libimagstorestdhook/src/flock.rs b/libimagstorestdhook/src/flock.rs index 2386180a..24673f0e 100644 --- a/libimagstorestdhook/src/flock.rs +++ b/libimagstorestdhook/src/flock.rs @@ -18,27 +18,23 @@ use libimagstore::store::FileLockEntry; use libimagstore::store::Entry; trait EntryFlock { - fn lock(&self, store_location: &PathBuf) -> IoResult<()>; - fn unlock(&self, store_location: &PathBuf) -> IoResult<()>; + fn lock(&self) -> IoResult<()>; + fn unlock(&self) -> IoResult<()>; } impl EntryFlock for Entry { - fn lock(&self, store_location: &PathBuf) -> IoResult<()> { + fn lock(&self) -> IoResult<()> { use std::fs::File; - let mut location = store_location.clone(); - location.push(self.get_location()); - + let location : PathBuf = self.get_location().clone().into(); File::open(location).and_then(|file| file.lock_exclusive()) } - fn unlock(&self, store_location: &PathBuf) -> IoResult<()> { + fn unlock(&self) -> IoResult<()> { use std::fs::File; - let mut location = store_location.clone(); - location.push(self.get_location()); - + let location : PathBuf = self.get_location().clone().into(); File::open(location).and_then(|file| file.unlock()) } @@ -60,15 +56,13 @@ fn action_to_str(a: &Action) -> &'static str { #[derive(Debug, Clone)] pub struct FlockUpdateHook { action: Action, - store_location: PathBuf, } impl FlockUpdateHook { - pub fn new(action: Action, store_location: PathBuf) -> FlockUpdateHook { + pub fn new(action: Action) -> FlockUpdateHook { FlockUpdateHook { action: action, - store_location: store_location, } } @@ -107,7 +101,7 @@ impl MutableHookDataAccessor for FlockUpdateHook { fn access_mut(&self, fle: &mut FileLockEntry) -> HookResult<()> { debug!("[FLOCK HOOK][{}] {:?}", action_to_str(&self.action), fle.get_location()); - fle.lock(&self.store_location) + fle.lock() .map_err(|e| HookError::new(HookErrorKind::HookExecutionError, Some(Box::new(e)))) .map(|_| ()) } @@ -118,7 +112,7 @@ impl NonMutableHookDataAccessor for FlockUpdateHook { fn access(&self, fle: &FileLockEntry) -> HookResult<()> { debug!("[FLOCK HOOK][{}] {:?}", action_to_str(&self.action), fle.get_location()); - fle.unlock(&self.store_location) + fle.unlock() .map_err(|e| HookError::new(HookErrorKind::HookExecutionError, Some(Box::new(e)))) .map(|_| ()) } diff --git a/libimagstorestdhook/src/linkverify.rs b/libimagstorestdhook/src/linkverify.rs index e97981b7..93efd9a6 100644 --- a/libimagstorestdhook/src/linkverify.rs +++ b/libimagstorestdhook/src/linkverify.rs @@ -53,8 +53,7 @@ impl NonMutableHookDataAccessor for LinkedEntriesExistHook { let _ = fle.get_internal_links() .map(|links| { for link in links { - let mut path = self.store_location.clone(); - path.push(link); + let path : PathBuf = link.into(); if !path.exists() { warn!("File link does not exist: {:?} -> {:?}", fle.get_location(), path); } else if !path.is_file() {