diff --git a/qBitrr/config.py b/qBitrr/config.py index 823ecfca..c56f1f99 100644 --- a/qBitrr/config.py +++ b/qBitrr/config.py @@ -2,13 +2,15 @@ import argparse import contextlib +import os import pathlib import shutil +import signal import sys from qBitrr.bundled_data import license_text, patched_version from qBitrr.env_config import ENVIRO_CONFIG -from qBitrr.gen_config import MyConfig, generate_doc +from qBitrr.gen_config import MyConfig, _write_config_file, generate_doc from qBitrr.home_path import APPDATA_FOLDER, HOME_PATH, ON_DOCKER @@ -82,24 +84,21 @@ def process_flags() -> argparse.Namespace | bool: elif (not CONFIG_FILE.exists()) and (not CONFIG_PATH.exists()): if ON_DOCKER: print(f"{file} has not been found") - from qBitrr.gen_config import _write_config_file CONFIG_FILE = _write_config_file(docker=True) print(f"'{CONFIG_FILE.name}' has been generated") print('Rename it to "config.toml" then edit it and restart the container') - import os - import signal os.kill(os.getppid(), signal.SIGTERM) else: print(f"{file} has not been found") - print(f"{file} must be added to {CONFIG_FILE}") - print( - "You can run me with the `--gen-config` flag to generate a " - "template config file which you can then edit." - ) - sys.exit(1) + + CONFIG_FILE = _write_config_file(docker=True) + print(f"'{CONFIG_FILE.name}' has been generated") + print('Rename it to "config.toml" then edit it and restart the container') + + os.kill(os.getppid(), signal.SIGTERM) elif CONFIG_FILE.exists(): CONFIG = MyConfig(CONFIG_FILE) diff --git a/qBitrr/home_path.py b/qBitrr/home_path.py index 3ed19ca4..93e2fb81 100644 --- a/qBitrr/home_path.py +++ b/qBitrr/home_path.py @@ -14,7 +14,7 @@ HOME_PATH.mkdir(parents=True, exist_ok=True) else: ON_DOCKER = False - HOME_PATH = pathlib.Path().home().joinpath(".qBitrr") + HOME_PATH = pathlib.Path().absolute().joinpath(".config") HOME_PATH.mkdir(parents=True, exist_ok=True) else: HOME_PATH = p