From dbe0465cf1886699ae3a04a54890a3bd503fbe52 Mon Sep 17 00:00:00 2001 From: Tpt Date: Wed, 28 Apr 2021 18:20:24 +0200 Subject: [PATCH] Exposes Sled flush operation Required to materialize changes on some platforms (Android, Windows...) Bug #99 --- lib/src/store/sled.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/src/store/sled.rs b/lib/src/store/sled.rs index 3c477280..e52b54a5 100644 --- a/lib/src/store/sled.rs +++ b/lib/src/store/sled.rs @@ -664,6 +664,28 @@ impl SledStore { (&mut this).clear() } + /// Flushes all buffers and ensures that all writes are saved on disk. + /// + /// Flushes are automatically done for most platform using background threads. + /// However, calling this method explicitly is still required for Windows and Android. + /// + /// An [async version](SledStore::flush_async) is also available. + pub fn flush(&self) -> Result<(), io::Error> { + self.default.flush()?; + Ok(()) + } + + /// Asynchronously flushes all buffers and ensures that all writes are saved on disk. + /// + /// Flushes are automatically done for most platform using background threads. + /// However, calling this method explicitly is still required for Windows and Android. + /// + /// A [sync version](SledStore::flush) is also available. + pub async fn flush_async(&self) -> Result<(), io::Error> { + self.default.flush_async().await?; + Ok(()) + } + fn contains_encoded(&self, quad: &EncodedQuad) -> Result { let mut buffer = Vec::with_capacity(4 * WRITTEN_TERM_MAX_SIZE); if quad.graph_name.is_default_graph() {