database: sync the database before closing
This should prevent the database from losing entries on a reboot. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
d9d087b9f3
commit
3f48dd5510
|
@ -298,9 +298,10 @@ class MoonrakerDatabase:
|
||||||
with self.lmdb_env.begin() as txn:
|
with self.lmdb_env.begin() as txn:
|
||||||
for db_name, db in self.namespaces.items():
|
for db_name, db in self.namespaces.items():
|
||||||
stats = txn.stat(db)
|
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()])
|
msg += "\n".join([f"{k}: {v}" for k, v in stats.items()])
|
||||||
logging.info(f"Database statistics:\n{msg}")
|
logging.info(f"Database statistics:\n{msg}")
|
||||||
|
self.lmdb_env.sync()
|
||||||
self.lmdb_env.close()
|
self.lmdb_env.close()
|
||||||
|
|
||||||
class NamespaceWrapper:
|
class NamespaceWrapper:
|
||||||
|
|
Loading…
Reference in New Issue