mirror of
https://github.com/LmeSzinc/AzurLaneAutoScript.git
synced 2025-01-09 05:47:30 +08:00
Fix: The behavior of saving the configuration will be atomic
This commit is contained in:
parent
919d52f84e
commit
100c02ed62
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,6 +6,7 @@ config/*.ini
|
||||
config/*.yaml
|
||||
!config/deploy.*.yaml
|
||||
config/*.json
|
||||
config/tmp*
|
||||
!config/template.json
|
||||
*.pyw
|
||||
dev_tools/debug_tools
|
||||
|
@ -20,4 +20,5 @@ wrapt==1.13.1
|
||||
prettytable==2.2.1
|
||||
pypresence==4.2.1
|
||||
rich==11.0.0
|
||||
zerorpc
|
||||
zerorpc
|
||||
atomicwrites
|
@ -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:
|
||||
|
@ -22,4 +22,5 @@ prettytable==2.2.1
|
||||
pypresence==4.2.1
|
||||
alas-webapp==0.3.7
|
||||
rich==11.0.0
|
||||
zerorpc
|
||||
zerorpc
|
||||
atomicwrites
|
@ -11,6 +11,7 @@ anyio==1.3.1 # via -r requirements-in.txt
|
||||
apkutils2==1.0.0 # via adbutils
|
||||
asgiref==3.4.1 # via uvicorn
|
||||
async-generator==1.10 # via anyio
|
||||
atomicwrites==1.4.0 # via -r requirements-in.txt
|
||||
cached-property==1.5.2 # via uiautomator2
|
||||
certifi==2021.5.30 # via requests
|
||||
cffi==1.15.0 # via gevent
|
||||
|
Loading…
Reference in New Issue
Block a user