利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.
Python ai-video-generatorcontent-creationffmpeginstagram-reelsllmpythonshort-videosubtitlestext-to-speechtiktokvideo-automationvideo-workflowworkflow-automationyoutube-shorts
fix(config): preserve nonempty config directory on startup
Rudy Celeklib04ab45f7ea8
diff --git a/app/config/config.py b/app/config/config.pyindex 95452d20..f7dedea4 100644--- a/app/config/config.py+++ b/app/config/config.py@@ -458,9 +458,16 @@ def _load_toml_config(config_path: str):def load_config():- # fix: IsADirectoryError: [Errno 21] Is a directory: '/MoneyPrinterTurbo/config.toml'+ # Docker may create an empty directory when a missing config.toml is bind-mounted.+ # Only remove that empty placeholder; a nonempty directory may contain user data.if os.path.isdir(config_file):- shutil.rmtree(config_file)+ try:+ os.rmdir(config_file)+ except OSError as exc:+ raise IsADirectoryError(+ f"{config_file} is a directory and cannot be used as the config file; "+ "move or rename it, then restart"+ ) from excif not os.path.isfile(config_file):example_file = f"{root_dir}/config.example.toml"diff --git a/test/services/test_config.py b/test/services/test_config.pyindex e304b87b..8b546a05 100644--- a/test/services/test_config.py+++ b/test/services/test_config.py@@ -8,6 +8,7 @@ from tempfile import TemporaryDirectoryfrom unittest.mock import patchimport toml+import pytestfrom app.config import configfrom app.models.llm_provider import LLM_PROVIDER_REGISTRY, get_llm_provider@@ -164,6 +165,46 @@ class TestConfigPersistence:assert str(config_path) in error_messageassert "TomlDecodeError" in error_message+ def test_load_config_recovers_empty_config_directory(self):+ """Docker can create an empty directory at a missing file bind-mount path."""+ with TemporaryDirectory() as temp_dir:+ root = Path(temp_dir)+ config_path = root / "config.toml"+ config_path.mkdir()+ (root / "config.example.toml").write_text(+ '[app]\nvideo_source = "pexels"\n', encoding="utf-8"+ )++ with (+ patch.object(config, "root_dir", temp_dir),+ patch.object(config, "config_file", str(config_path)),+ ):+ loaded_config = config.load_config()++ assert loaded_config["app"]["video_source"] == "pexels"+ assert config_path.is_file()++ def test_load_config_preserves_nonempty_config_directory(self):+ """A mistaken config.toml directory must not be recursively deleted."""+ with TemporaryDirectory() as temp_dir:+ root = Path(temp_dir)+ config_path = root / "config.toml"+ config_path.mkdir()+ sentinel = config_path / "user-data.txt"+ sentinel.write_text("keep this file", encoding="utf-8")+ (root / "config.example.toml").write_text(+ '[app]\nvideo_source = "pexels"\n', encoding="utf-8"+ )++ with (+ patch.object(config, "root_dir", temp_dir),+ patch.object(config, "config_file", str(config_path)),+ ):+ with pytest.raises(IsADirectoryError, match="config.toml"):+ config.load_config()++ assert sentinel.read_text(encoding="utf-8") == "keep this file"+def test_kimi_uses_current_default_model(self):"""Kimi 未配置模型覆盖值时,应使用当前发布版本的默认模型。"""provider = get_llm_provider("moonshot")