From cb09d88322b58db20b576f35a0319131efc20162 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Fri, 24 Apr 2015 21:01:34 +0200 Subject: [PATCH] fix bug introduced in 21673c95f4b9546e115fa8a128b0c6bb8c74d4b0 --- lib/wallet.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/wallet.py b/lib/wallet.py index 4ef50c72..6bf0af96 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -139,8 +139,12 @@ class WalletStorage(object): s = json.dumps(self.data, indent=4, sort_keys=True) with open(temp_path, "w") as f: f.write(s) - os.remove(self.path) - os.rename(temp_path, self.path) + # perform atomic write on POSIX systems + try: + os.rename(temp_path, self.path) + except: + os.remove(self.path) + 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)