diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-02-21 17:39:57 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-02-21 17:39:57 +0100 |
commit | 44a22a225e3a3d14176189e42e3715f477804e57 (patch) | |
tree | e1853e747952ef37e0435c632ba9e4203b66b83c | |
parent | b3a4c33451b147d840e3b891500c8360778dcd28 (diff) |
TMP: Revert "Revert "Check whether entry is borrowed before using it""
This reverts commit 00c107f9528e782aea72e324774176b3966320f4.
-rw-r--r-- | lib/domain/libimagmail/src/mailtree.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/domain/libimagmail/src/mailtree.rs b/lib/domain/libimagmail/src/mailtree.rs index dff4ed58..4eaec410 100644 --- a/lib/domain/libimagmail/src/mailtree.rs +++ b/lib/domain/libimagmail/src/mailtree.rs @@ -17,6 +17,8 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // +use std::path::PathBuf; + use failure::Fallible as Result; use failure::ResultExt; use indextree::Arena; @@ -24,10 +26,13 @@ use indextree::NodeId; use indextree::Node; use itertools::Itertools; +use libimagstore::storeid::StoreId; + use crate::store::MailStoreWithConnection; use crate::mail::Mail; use crate::mail::LoadedMail; + #[derive(Debug)] pub struct Mailtree { arena: Arena<String>, @@ -101,6 +106,15 @@ fn fill_arena_with<'a>(arena: &mut Arena<String>, store: &'a MailStoreWithConnec .into_iter() .map(|id: String| { trace!("Trying to get: {:?}", id); + + { + let sid = StoreId::new(PathBuf::from(id.clone()))?; + if store.is_borrowed(sid)? { + trace!("Entry is already borrowed, returning"); + return Ok(()) + } + } + let mail = store.get_mail_by_id(&id) .context("Getting mail by id")? .ok_or_else(|| format_err!("Cannot find mail for id {}", id))?; |