~matthiasbeyer/imag

17fc7e77d9793e2ecd53af02edfee1aa5e53e899 — Matthias Beyer 2 years ago 418535e + 009b608
Merge branch 'libimagstore/is-borrowed' into master

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
1 files changed, 12 insertions(+), 0 deletions(-)

M lib/core/libimagstore/src/store.rs
M lib/core/libimagstore/src/store.rs => lib/core/libimagstore/src/store.rs +12 -0
@@ 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