diff --git a/src/module/conf/config.py b/src/module/conf/config.py index 9570512b..1e5826f4 100644 --- a/src/module/conf/config.py +++ b/src/module/conf/config.py @@ -52,10 +52,21 @@ def env_to_config() -> Config: if os.path.isdir("config") and VERSION == "DEV_VERSION": CONFIG_PATH = "config/config_dev.json" - settings = load_config_from_file(CONFIG_PATH) - print(dict(settings)) + if os.path.isfile(CONFIG_PATH): + settings = load_config_from_file(CONFIG_PATH) + else: + settings = env_to_config() + save_config_to_file(settings, CONFIG_PATH) elif os.path.isdir("config") and VERSION != "DEV_VERSION": CONFIG_PATH = "config/config.json" + if os.path.isfile(CONFIG_PATH): + settings = load_config_from_file(CONFIG_PATH) + else: + settings = env_to_config() + save_config_to_file(settings, CONFIG_PATH) +else: + settings = Config() + diff --git a/src/module/models/config.py b/src/module/models/config.py index a4d5a6b7..b2d0a62b 100644 --- a/src/module/models/config.py +++ b/src/module/models/config.py @@ -60,10 +60,10 @@ class Notification(BaseModel): class Config(BaseModel): data_version: float = Field(4.0, description="Data version") - program: Program - downloader: Downloader - rss_parser: RSSParser - bangumi_manage: BangumiManage - debug: Debug - proxy: Proxy - notification: Notification + program: Program = Program() + downloader: Downloader = Downloader() + rss_parser: RSSParser = RSSParser() + bangumi_manage: BangumiManage = BangumiManage() + debug: Debug = Debug() + proxy: Proxy = Proxy() + notification: Notification = Notification()