electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 05ebd0f5b223a7e39eb1b1c0bb3ac949c061cec9
parent 6443bb7d8dce267c9c76e63a033526d3d8afe575
Author: SomberNight <somber.night@protonmail.com>
Date:   Wed,  7 Oct 2020 19:41:22 +0200

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

related: #4110, #6358

Diffstat:
Melectrum/storage.py | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/electrum/storage.py b/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)