accountsdb: use shutil.move instead of os.rename

On Windows, os.rename will error if the destination exists
This commit is contained in:
James Lu 2023-04-27 23:26:14 -07:00
parent 79a4453875
commit edeb892db1
3 changed files with 5 additions and 5 deletions

View File

@ -1,4 +1,4 @@
# Autogenerated by update-modules.py on Sat Mar 9 12:35:58 2019 - DO NOT EDIT THIS COPY DIRECTLY! # Autogenerated by update-modules.py on Thu Apr 27 23:26:05 2023 - DO NOT EDIT THIS COPY DIRECTLY!
### ###
# Copyright (c) 2019, James Lu <james@overdrivenetworks.com> # Copyright (c) 2019, James Lu <james@overdrivenetworks.com>
# All rights reserved. # All rights reserved.
@ -91,7 +91,7 @@ class AccountsDB():
try: try:
with open(tmp_filename, 'wb') as f: with open(tmp_filename, 'wb') as f:
pickle.dump(self.db, f, 2) pickle.dump(self.db, f, 2)
os.rename(tmp_filename, self.filename) shutil.move(tmp_filename, self.filename)
except Exception as e: except Exception as e:
log.exception('%s: Unable to write database: %s', self._plugin_name, e) log.exception('%s: Unable to write database: %s', self._plugin_name, e)

View File

@ -1,4 +1,4 @@
# Autogenerated by update-modules.py on Sat Mar 9 12:35:58 2019 - DO NOT EDIT THIS COPY DIRECTLY! # Autogenerated by update-modules.py on Thu Apr 27 23:26:05 2023 - DO NOT EDIT THIS COPY DIRECTLY!
### ###
# Copyright (c) 2019, James Lu <james@overdrivenetworks.com> # Copyright (c) 2019, James Lu <james@overdrivenetworks.com>
# All rights reserved. # All rights reserved.
@ -91,7 +91,7 @@ class AccountsDB():
try: try:
with open(tmp_filename, 'wb') as f: with open(tmp_filename, 'wb') as f:
pickle.dump(self.db, f, 2) pickle.dump(self.db, f, 2)
os.rename(tmp_filename, self.filename) shutil.move(tmp_filename, self.filename)
except Exception as e: except Exception as e:
log.exception('%s: Unable to write database: %s', self._plugin_name, e) log.exception('%s: Unable to write database: %s', self._plugin_name, e)

View File

@ -90,7 +90,7 @@ class AccountsDB():
try: try:
with open(tmp_filename, 'wb') as f: with open(tmp_filename, 'wb') as f:
pickle.dump(self.db, f, 2) pickle.dump(self.db, f, 2)
os.rename(tmp_filename, self.filename) shutil.move(tmp_filename, self.filename)
except Exception as e: except Exception as e:
log.exception('%s: Unable to write database: %s', self._plugin_name, e) log.exception('%s: Unable to write database: %s', self._plugin_name, e)