From 7c2131209fdf57d3a7f5d867dfaba3ddbb2f01ab Mon Sep 17 00:00:00 2001 From: SomberNight Date: Thu, 2 Nov 2023 16:59:53 +0000 Subject: [PATCH] config: handle better if data dir disappears while we are running related https://github.com/spesmilo/electrum/issues/4151#issuecomment-1791117301 closes https://github.com/spesmilo/electrum/issues/4151 --- electrum/simple_config.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/electrum/simple_config.py b/electrum/simple_config.py index 7a6bf1f38..d4d19a296 100644 --- a/electrum/simple_config.py +++ b/electrum/simple_config.py @@ -416,8 +416,10 @@ class SimpleConfig(Logger): with open(path, "w", encoding='utf-8') as f: f.write(s) os_chmod(path, stat.S_IREAD | stat.S_IWRITE) - except FileNotFoundError: - # datadir probably deleted while running... + except OSError: + # datadir probably deleted while running... e.g. portable exe running on ejected USB drive + # (in which case it is typically either FileNotFoundError or PermissionError, + # but let's just catch the more generic OSError and test explicitly) if os.path.exists(self.path): # or maybe not? raise