summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-01-03 14:04:12 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-01-03 14:04:12 +0100
commit17fc7e77d9793e2ecd53af02edfee1aa5e53e899 (patch)
treedae94c2aa2cf6c9ae217dfc247523b7e5a62d991
parent418535ec97b5684e9556e6e8152ed3007a122814 (diff)
parent009b608871de302ab04e1b664727958df8cbafba (diff)
downloadimag-17fc7e77d9793e2ecd53af02edfee1aa5e53e899.zip
imag-17fc7e77d9793e2ecd53af02edfee1aa5e53e899.tar.gz
Merge branch 'libimagstore/is-borrowed' into master
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--lib/core/libimagstore/src/store.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/core/libimagstore/src/store.rs b/lib/core/libimagstore/src/store.rs
index 2661296..5137b51 100644
--- a/lib/core/libimagstore/src/store.rs
+++ b/lib/core/libimagstore/src/store.rs
@@ -216,6 +216,18 @@ impl Store {
Ok(store)
}
+ pub fn is_borrowed<S: IntoStoreId>(&self, id: S) -> Result<bool> {
+ let id = id.into_storeid()?;
+ debug!("Checking whether id is borrowed: '{}'", id);
+
+ self.entries
+ .read()
+ .map_err(|_| Error::from(EM::LockError))
+ .context(format_err!("Error while checking whether {} is borrowed", id))
+ .map(|cache| cache.get(&id).map(|e| e.is_borrowed()).unwrap_or(false))
+ .map_err(Error::from)
+ }
+
/// Creates the Entry at the given location (inside the entry)
///
/// # Return value