Attempt to fix config handling on Windows

This commit is contained in:
Leo Vasanko 2023-11-13 16:31:35 -08:00
parent 3e50149d4d
commit 61f9026e23

View File

@ -1,6 +1,7 @@
from __future__ import annotations from __future__ import annotations
import secrets import secrets
import sys
from functools import wraps from functools import wraps
from hashlib import sha256 from hashlib import sha256
from pathlib import Path, PurePath from pathlib import Path, PurePath
@ -90,6 +91,8 @@ def config_update(modify):
return "read" return "read"
f.write(new) f.write(new)
f.close() f.close()
if sys.platform == "win32":
conffile.unlink() # Windows doesn't support atomic replace
tmpname.rename(conffile) # Atomic replace tmpname.rename(conffile) # Atomic replace
except: except:
f.close() f.close()