1
0

storage.write: make os_chmod best-effort

closes https://github.com/spesmilo/electrum/issues/8409
closes https://github.com/spesmilo/electrum/pull/8997
This commit is contained in:
SomberNight
2025-09-05 19:51:33 +00:00
parent 969deb2cd9
commit 9d13855c99

View File

@@ -104,7 +104,10 @@ class WalletStorage(Logger):
s = self.encrypt_before_writing(data)
temp_path = "%s.tmp.%s" % (self.path, os.getpid())
with open(temp_path, "wb") as f:
os_chmod(temp_path, mode) # set restrictive perms *before* we write data
try:
os_chmod(temp_path, mode) # set restrictive perms *before* we write data
except PermissionError as e: # tolerate NFS or similar weirdness?
self.logger.warning(f"cannot chmod temp wallet file: {e!r}")
f.write(s.encode("utf-8"))
self.pos = f.seek(0, os.SEEK_END)
f.flush()