This commit is contained in:
Alvin-Zilverstand committed 2026-11-13 10:05:28 +01:00
1 parent ed76261303
commit 918bc45ee0
4 files changed
+20 -5

No files matched your search

+4 -1
View File
@@ -36,13 +36,16 @@ def save_settings(data, path=DEFAULT_PATH):
flags = os.O_WRONLY | os.O_CREAT | os.O_EXCL
if hasattr(os, 'O_BINARY'):
flags |= os.O_BINARY
created = False
try:
descriptor = os.open(temporary, flags, 0o600)
created = True
with os.fdopen(descriptor, 'w', encoding='utf-8') as output:
output.write(json.dumps(data, indent=2, ensure_ascii=False) + '\n')
os.replace(temporary, path)
except BaseException:
temporary.unlink(missing_ok=True)
if created:
temporary.unlink(missing_ok=True)
raise