1
0

json_db: rename "_write" to sth more descriptive

This commit is contained in:
SomberNight
2023-11-27 15:30:26 +00:00
parent ae9767880e
commit 6467db0b7d
3 changed files with 9 additions and 8 deletions

View File

@@ -226,7 +226,7 @@ class JsonDB(Logger):
self.data = StoredDict(data, self, [])
# write file in case there was a db upgrade
if self.storage and self.storage.file_exists():
self._write()
self.write_and_force_consolidation()
def load_data(self, s:str) -> dict:
""" overloaded in wallet_db """
@@ -381,10 +381,10 @@ class JsonDB(Logger):
@locked
def write(self):
if not self.storage.file_exists()\
or self.storage.is_encrypted()\
or self.storage.needs_consolidation():
self._write()
if (not self.storage.file_exists()
or self.storage.is_encrypted()
or self.storage.needs_consolidation()):
self.write_and_force_consolidation()
else:
self._append_pending_changes()
@@ -402,7 +402,7 @@ class JsonDB(Logger):
@locked
@profiler
def _write(self):
def write_and_force_consolidation(self):
if threading.current_thread().daemon:
raise Exception('daemon thread cannot write db')
if not self.modified():