From 3f48dd5510817ea56a385cc614d4ab197382edba Mon Sep 17 00:00:00 2001 From: Arksine Date: Wed, 17 Mar 2021 06:53:20 -0400 Subject: [PATCH] database: sync the database before closing This should prevent the database from losing entries on a reboot. Signed-off-by: Eric Callahan --- moonraker/plugins/database.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/moonraker/plugins/database.py b/moonraker/plugins/database.py index af0867c..5f0f90e 100644 --- a/moonraker/plugins/database.py +++ b/moonraker/plugins/database.py @@ -298,9 +298,10 @@ class MoonrakerDatabase: with self.lmdb_env.begin() as txn: for db_name, db in self.namespaces.items(): stats = txn.stat(db) - msg += f"\n{db_name}:" + msg += f"\n{db_name}:\n" msg += "\n".join([f"{k}: {v}" for k, v in stats.items()]) logging.info(f"Database statistics:\n{msg}") + self.lmdb_env.sync() self.lmdb_env.close() class NamespaceWrapper: