mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-12 10:58:21 +08:00
Fix: The behavior of saving the configuration will be atomic
This commit is contained in:
@@ -4,6 +4,7 @@ import random
|
||||
import string
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from filelock import FileLock
|
||||
from atomicwrites import atomic_write
|
||||
|
||||
import yaml
|
||||
|
||||
@@ -119,7 +120,7 @@ def write_file(file, data):
|
||||
yaml.safe_dump(data, f, default_flow_style=False, encoding='utf-8', allow_unicode=True,
|
||||
sort_keys=False)
|
||||
elif ext == '.json':
|
||||
with open(file, mode='w', encoding='utf-8') as f:
|
||||
with atomic_write(file, overwrite=True, encoding='utf-8') as f:
|
||||
s = json.dumps(data, indent=2, ensure_ascii=False, sort_keys=False, default=str)
|
||||
f.write(s)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user