From 74a80f6ec446336aebd212c57b49689ac1de197f Mon Sep 17 00:00:00 2001 From: Joscha Date: Fri, 17 Jun 2022 14:48:01 +0200 Subject: [PATCH] Ensure db is closed properly when exiting --- cove-tui/src/vault.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cove-tui/src/vault.rs b/cove-tui/src/vault.rs index e51eb0c..f31b9e0 100644 --- a/cove-tui/src/vault.rs +++ b/cove-tui/src/vault.rs @@ -24,8 +24,13 @@ impl Vault { fn run(conn: Connection, mut rx: mpsc::Receiver) -> anyhow::Result<()> { while let Some(request) = rx.blocking_recv() { match request { - // Drops the Sender resulting in `Vault::close` exiting - Request::Close(_) => break, + Request::Close(tx) => { + // Ensure `Vault::close` exits only after the sqlite connection + // has been closed properly. + drop(conn); + drop(tx); + break; + } Request::Nop => {} } }