From babf74e1e52469eb2ad41d3a40496d6db7016171 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 20 Sep 2016 16:52:14 +0200 Subject: [PATCH] Fix Store::get() to not check FS but internal hashmap --- libimagstore/src/store.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index f19a5eff..b6a9c8ad 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -459,11 +459,20 @@ impl Store { /// /// This executes the {pre,post}_retrieve_aspects hooks. pub fn get<'a, S: IntoStoreId + Clone>(&'a self, id: S) -> Result>> { - let id_copy = try!(id.clone().into_storeid()).with_base(self.path().clone()); - if !id_copy.exists() { - debug!("Does not exist: {:?}", id_copy); + let id = try!(id.into_storeid()).with_base(self.path().clone()); + + let exists = try!(self.entries + .read() + .map(|map| map.contains_key(&id)) + .map_err(|_| SE::new(SEK::LockPoisoned, None)) + .map_err_into(SEK::GetCallError) + ); + + if !exists && !id.exists() { + debug!("Does not exist in internal cache or filesystem: {:?}", id); return Ok(None); } + self.retrieve(id).map(Some).map_err_into(SEK::GetCallError) }