Skip to content

Commit

Permalink
Emergency sync: config broke everything on old installs (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChanceNCounter authored Apr 9, 2021
1 parent b484b07 commit 358fea5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bak/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BAK_VERSION = "0.2.0a1"
BAK_VERSION = "0.2.1a1"
7 changes: 5 additions & 2 deletions bak/configuration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from pathlib import Path
from re import sub
from shutil import copy2

from config import Config, KeyNotFoundError

Expand Down Expand Up @@ -50,13 +51,15 @@ def __init__(self):
self.config_dir = Path("~/.config").expanduser().resolve()

self.config_file = self.config_dir / 'bak.cfg'
if not self.config_file.exists():
copy2(self.config_dir / 'bak.cfg.default', self.config_file)
_cfg = Config(str(self.config_file))

reload = False
for cfg_value in self.DEFAULT_VALUES:
if cfg_value not in _cfg.as_dict():
with open(self.config_file, 'w') as _file:
_file.write(
with open(self.config_file, 'a') as _file:
_file.writelines(
f"{cfg_value}: {self.DEFAULT_VALUES[cfg_value]}\n")
_file.close()
reload = True
Expand Down
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
'rich==9.1.0']

setup(name='bak',
version='0.2.0a1',
version='0.2.1a1',
description='the .bak manager',
author='ChanceNCounter',
author_email='ChanceNCounter@icloud.com',
Expand All @@ -28,6 +28,11 @@
config_dir = os.path.expanduser("~/.config")

config_file = os.path.join(config_dir, 'bak.cfg')
default_config = os.path.join(config_dir, 'bak.cfg.default')

if not os.path.exists(config_file):
copy2('bak/default.cfg', config_file)

if not os.path.exists(default_config):
copy2('bak/default.cfg', default_config)

0 comments on commit 358fea5

Please sign in to comment.