Revert "Create config file if it doesn't exist"

This reverts commit 310f70ac5f.
This commit is contained in:
planet36 2020-10-11 23:16:46 -04:00
parent 310f70ac5f
commit 610580b704
1 changed files with 4 additions and 9 deletions

View File

@ -71,7 +71,6 @@ KeyError: 'ConfigBase::get_item: unknown key algo'
""" """
import os import os
import pathlib
import shutil import shutil
from copy import copy from copy import copy
from configobj import ConfigObj, flatten_errors from configobj import ConfigObj, flatten_errors
@ -720,19 +719,15 @@ class ConfigBase(Borg):
config_dir = get_config_dir() config_dir = get_config_dir()
if not os.path.isdir(config_dir): if not os.path.isdir(config_dir):
os.makedirs(config_dir) os.makedirs(config_dir)
config_file = pathlib.Path(self.command_line_options.config)
if not config_file.is_file():
config_file.touch()
try: try:
backup_file = config_file.with_suffix('.bak') backup_file = self.command_line_options.config + '~'
shutil.copy2(config_file, backup_file) shutil.copy2(self.command_line_options.config, backup_file)
with open(config_file, 'wb') as fh: with open(self.command_line_options.config, 'wb') as fh:
parser.write(fh) parser.write(fh)
backup_file.unlink() os.remove(backup_file)
except Exception as ex: except Exception as ex:
err('ConfigBase::save: Unable to save config: %s' % ex) err('ConfigBase::save: Unable to save config: %s' % ex)