Browse Source

storage: try to handle user deleting/renaming wallet file while running

related: #4110, #6358
patch-4
SomberNight 4 years ago
parent
commit
05ebd0f5b2
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 8
      electrum/storage.py

8
electrum/storage.py

@ -87,7 +87,13 @@ class WalletStorage(Logger):
f.flush()
os.fsync(f.fileno())
mode = os.stat(self.path).st_mode if self.file_exists() else stat.S_IREAD | stat.S_IWRITE
default_mode = stat.S_IREAD | stat.S_IWRITE
try:
mode = os.stat(self.path).st_mode if self.file_exists() else default_mode
except FileNotFoundError:
# user might have deleted/renamed file while running
mode = default_mode
# assert that wallet file does not exist, to prevent wallet corruption (see issue #5082)
if not self.file_exists():
assert not os.path.exists(self.path)

Loading…
Cancel
Save