Merge pull request #4 from htmltiger/htmltiger-patch-1

preserve permissions
This commit is contained in:
htmltiger 2022-02-04 13:56:11 +00:00 committed by GitHub
commit 1a37682e32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -77,9 +77,13 @@ async def websocket_create(hass, connection, msg):
dirnm = os.path.dirname(fullpath)
if not os.path.isdir(dirnm):
os.makedirs(dirnm, exist_ok=True)
try:
mode = os.stat(fullpath).st_mode
except:
mode = 0o666
with AtomicWriter(fullpath, overwrite=True).open() as fdesc:
try:
os.fchmod(fdesc.fileno(), 0o666)
os.fchmod(fdesc.fileno(), mode)
except:
pass
fdesc.write(content)