diff --git a/core/__init__.py b/core/__init__.py index 92ada79..870c14c 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -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)