From 7bd37e397202722832c8ea99e90312a568e46070 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Sat, 22 Oct 2016 15:22:34 +0200 Subject: [PATCH] flush DB changes on drop (#2795) --- util/src/kvdb.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/util/src/kvdb.rs b/util/src/kvdb.rs index 7d6ea399c..4c5b7a3d0 100644 --- a/util/src/kvdb.rs +++ b/util/src/kvdb.rs @@ -595,6 +595,13 @@ impl Database { } } +impl Drop for Database { + fn drop(&mut self) { + // write all buffered changes if we can. + let _ = self.flush(); + } +} + #[cfg(test)] mod tests { use hash::*;