diff --git a/LastFM/local/accountsdb.py b/LastFM/local/accountsdb.py index 65296ca..53355fb 100644 --- a/LastFM/local/accountsdb.py +++ b/LastFM/local/accountsdb.py @@ -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) diff --git a/NuWeather/local/accountsdb.py b/NuWeather/local/accountsdb.py index 65296ca..53355fb 100644 --- a/NuWeather/local/accountsdb.py +++ b/NuWeather/local/accountsdb.py @@ -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) diff --git a/accountsdb.py b/accountsdb.py index 99442d6..53c198e 100644 --- a/accountsdb.py +++ b/accountsdb.py @@ -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)