mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
storage: take the DB lock when writing to disk.
This commit is contained in:
parent
73e656522e
commit
63963323be
2 changed files with 1 additions and 6 deletions
|
@ -61,9 +61,6 @@ class JsonDB(Logger):
|
|||
return True
|
||||
return False
|
||||
|
||||
def commit(self):
|
||||
pass
|
||||
|
||||
@locked
|
||||
def dump(self):
|
||||
return json.dumps(self.data, indent=4, sort_keys=True, cls=JsonDBJsonEncoder)
|
||||
|
|
|
@ -57,7 +57,6 @@ class WalletStorage(Logger):
|
|||
|
||||
def __init__(self, path, *, manual_upgrades: bool = False):
|
||||
Logger.__init__(self)
|
||||
self.lock = threading.RLock()
|
||||
self.path = standardize_path(path)
|
||||
self._file_exists = bool(self.path and os.path.exists(self.path))
|
||||
self._manual_upgrades = manual_upgrades
|
||||
|
@ -112,7 +111,7 @@ class WalletStorage(Logger):
|
|||
|
||||
@profiler
|
||||
def write(self):
|
||||
with self.lock:
|
||||
with self.db.lock:
|
||||
self._write()
|
||||
|
||||
def _write(self):
|
||||
|
@ -121,7 +120,6 @@ class WalletStorage(Logger):
|
|||
return
|
||||
if not self.db.modified():
|
||||
return
|
||||
self.db.commit()
|
||||
s = self.encrypt_before_writing(self.db.dump())
|
||||
temp_path = "%s.tmp.%s" % (self.path, os.getpid())
|
||||
with open(temp_path, "w", encoding='utf-8') as f:
|
||||
|
|
Loading…
Add table
Reference in a new issue