commit 6fb974227ba924c877e50defc36d7a3006660ef4
parent 6ade5903dcd7631593a4d46b4988af1ac13ab857
Author: ThomasV <thomasv@electrum.org>
Date: Thu, 7 Feb 2019 13:56:11 +0100
fix #5082
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/electrum/storage.py b/electrum/storage.py
@@ -74,6 +74,7 @@ class JsonDB(PrintError):
self.db_lock = threading.RLock()
self.data = {}
self.path = os.path.normcase(os.path.abspath(path))
+ self._file_exists = self.path and os.path.exists(self.path)
self.modified = False
def get(self, key, default=None):
@@ -135,9 +136,10 @@ class JsonDB(PrintError):
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
+ mode = os.stat(self.path).st_mode if self.file_exists() else stat.S_IREAD | stat.S_IWRITE
os.replace(temp_path, self.path)
os.chmod(self.path, mode)
+ self._file_exists = True
self.print_error("saved", self.path)
self.modified = False
@@ -145,7 +147,7 @@ class JsonDB(PrintError):
return plaintext
def file_exists(self):
- return self.path and os.path.exists(self.path)
+ return self._file_exists
class WalletStorage(JsonDB):