mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-05-02 08:21:10 -05:00
accountsdb: write DB to a temporary file first
This commit is contained in:
parent
f3bfd9ff73
commit
e46915b58d
@ -86,9 +86,11 @@ class AccountsDB():
|
||||
|
||||
def flush(self):
|
||||
"""Exports the database to a file."""
|
||||
tmp_filename = self.filename + '.tmp'
|
||||
try:
|
||||
with open(self.filename, 'wb') as f:
|
||||
with open(tmp_filename, 'wb') as f:
|
||||
pickle.dump(self.db, f, 2)
|
||||
os.rename(tmp_filename, self.filename)
|
||||
except Exception as e:
|
||||
log.warning('%s: Unable to write database: %s', self._plugin_name, e)
|
||||
|
||||
|
@ -86,9 +86,11 @@ class AccountsDB():
|
||||
|
||||
def flush(self):
|
||||
"""Exports the database to a file."""
|
||||
tmp_filename = self.filename + '.tmp'
|
||||
try:
|
||||
with open(self.filename, 'wb') as f:
|
||||
with open(tmp_filename, 'wb') as f:
|
||||
pickle.dump(self.db, f, 2)
|
||||
os.rename(tmp_filename, self.filename)
|
||||
except Exception as e:
|
||||
log.warning('%s: Unable to write database: %s', self._plugin_name, e)
|
||||
|
||||
|
@ -85,9 +85,11 @@ class AccountsDB():
|
||||
|
||||
def flush(self):
|
||||
"""Exports the database to a file."""
|
||||
tmp_filename = self.filename + '.tmp'
|
||||
try:
|
||||
with open(self.filename, 'wb') as f:
|
||||
with open(tmp_filename, 'wb') as f:
|
||||
pickle.dump(self.db, f, 2)
|
||||
os.rename(tmp_filename, self.filename)
|
||||
except Exception as e:
|
||||
log.warning('%s: Unable to write database: %s', self._plugin_name, e)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user