From e9749a9b8c64d06e29e439acf084e94b4afff5f9 Mon Sep 17 00:00:00 2001 From: asdf Date: Mon, 29 Jun 2020 16:13:41 +1000 Subject: [PATCH] Add exists checks before making any changes to the datastore --- config.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config.py b/config.py index 561571c..00e0ca2 100644 --- a/config.py +++ b/config.py @@ -75,7 +75,8 @@ def init(): with defaults if any issues. """ - USER.datadir.mkdir(mode=0o755, exist_ok=True) + if not USER.datadir.exists(): + USER.datadir.mkdir(mode=0o755, exist_ok=True) if not is_readable(USER.datadir.stat().st_mode): print( @@ -84,7 +85,8 @@ def init(): ) USER.datadir.chmod(0o755) - USER.datafile.touch(mode=0o644, exist_ok=True) + if not USER.datafile.exists(): + USER.datafile.touch(mode=0o644, exist_ok=True) if not is_readable(USER.datafile.stat().st_mode): print(