Skip to content

Commit

Permalink
fix rename backup history file #30
Browse files Browse the repository at this point in the history
  • Loading branch information
mercurykd committed Feb 23, 2021
1 parent 93fd267 commit 6c2ec64
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/__init__.py
Expand Up @@ -410,5 +410,9 @@ def write_json_file(data, path):
path_backup = path + '.bkp'
with open(path_temp, 'w') as f:
f.write(json.dumps(data)) # write to temp file to ensure no data loss if exception raised here
try:
os.remove(path_backup)
except OSError:
pass
os.rename(path, path_backup) # create backup file in case rename is unsuccessful
os.rename(path_temp, path)

0 comments on commit 6c2ec64

Please sign in to comment.