Merge pull request 'Add exists checks before making any changes to the datastore' (#92) from avoid-modify-datastore into release

Reviewed-on: #92
This commit is contained in:
asdf 2020-07-03 00:47:14 -04:00
commit c6f89e9475
1 changed files with 4 additions and 2 deletions

View File

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