1
0

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
This commit is contained in:
SomberNight
2023-11-02 16:59:53 +00:00
parent d6a6f56ddf
commit 7c2131209f

View File

@@ -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