From edb8c99fbed8a8445dba08c5baa491dfa23b35c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Sun, 18 Oct 2020 17:19:04 +0200 Subject: [PATCH] Introduce a method to get the meta of an update on the UpdateStore --- src/update_store.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/update_store.rs b/src/update_store.rs index 55fa480f6..5bc90d1c4 100644 --- a/src/update_store.rs +++ b/src/update_store.rs @@ -170,4 +170,21 @@ impl UpdateStore { Ok(()) } + + /// Returns the update associated meta or `None` if the update deosn't exist. + pub fn update_meta(&self, update_id: u64) -> heed::Result> + where M: for<'a> Deserialize<'a>, + { + let rtxn = self.env.read_txn()?; + let key = BEU64::new(update_id); + + if let Some(meta) = self.pending_meta.get(&rtxn, &key)? { + return Ok(Some(meta)); + } + + match self.processed_meta.get(&rtxn, &key)? { + Some(meta) => Ok(Some(meta)), + None => Ok(None), + } + } }