tpreserve file permissions when saving wallet - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit a9f451decd3d967ab3e6199999ba02acee9e816b DIR parent f77f63e15834c7320ffe2e1e4589f1bfd941fd40 HTML Author: ThomasV <thomasv@electrum.org> Date: Tue, 20 Oct 2015 13:52:38 +0200 preserve file permissions when saving wallet Diffstat: M lib/wallet.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- DIR diff --git a/lib/wallet.py b/lib/wallet.py t@@ -125,6 +125,8 @@ class WalletStorage(PrintError): f.write(s) f.flush() os.fsync(f.fileno()) + + mode = os.stat(self.path).st_mode if os.path.exists(self.path) else stat.S_IREAD | stat.S_IWRITE # perform atomic write on POSIX systems try: os.rename(temp_path, self.path) t@@ -133,7 +135,7 @@ class WalletStorage(PrintError): os.rename(temp_path, self.path) if 'ANDROID_DATA' not in os.environ: import stat - os.chmod(self.path,stat.S_IREAD | stat.S_IWRITE) + os.chmod(self.path, mode) self.print_error("saved")