tatomic write wallet file - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 4a28c88946151decab069120de4361351acbdcec DIR parent ab0447d01e728a94e1da790bdc3e62f780c3b502 HTML Author: ThomasV <thomasv@gitorious> Date: Thu, 23 Apr 2015 17:12:02 +0200 atomic write wallet file Diffstat: M lib/wallet.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- DIR diff --git a/lib/wallet.py b/lib/wallet.py t@@ -136,8 +136,9 @@ class WalletStorage(object): def write(self): assert not threading.currentThread().isDaemon() s = json.dumps(self.data, indent=4, sort_keys=True) - with open(self.path,"w") as f: + with open(self.path + '.tmp', "w") as f: f.write(s) + os.rename(self.path + '.tmp', self.path) if 'ANDROID_DATA' not in os.environ: import stat os.chmod(self.path,stat.S_IREAD | stat.S_IWRITE)