Merge pull request #10205 from SomberNight/202509_storage_oschmod

storage.write: make os_chmod best-effort
This commit is contained in:
ghost43
2025-09-05 23:43:23 +00:00
committed by GitHub

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()