mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-09 01:16:50 +08:00
refactor: unify env path
This commit is contained in:
@@ -123,7 +123,7 @@ def set_env_setting(env: dict,
|
||||
v = ''
|
||||
else:
|
||||
v = str(v)
|
||||
set_key(settings.CONFIG_PATH / "app.env", k, v)
|
||||
set_key(SystemUtils.get_env_path(), k, v)
|
||||
return schemas.Response(success=True)
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ def set_setting(key: str, value: Union[list, dict, bool, int, str] = None,
|
||||
value = ''
|
||||
else:
|
||||
value = str(value)
|
||||
set_key(settings.CONFIG_PATH / "app.env", key, value)
|
||||
set_key(SystemUtils.get_env_path(), key, value)
|
||||
else:
|
||||
SystemConfigOper().set(key, value)
|
||||
return schemas.Response(success=True)
|
||||
|
||||
+3
-4
@@ -414,6 +414,8 @@ class Settings(BaseSettings):
|
||||
|
||||
class Config:
|
||||
case_sensitive = True
|
||||
env_file = SystemUtils.get_env_path()
|
||||
env_file_encoding = "utf-8"
|
||||
|
||||
|
||||
class GlobalVar(object):
|
||||
@@ -451,10 +453,7 @@ class GlobalVar(object):
|
||||
|
||||
|
||||
# 实例化配置
|
||||
settings = Settings(
|
||||
_env_file=Settings().CONFIG_PATH / "app.env",
|
||||
_env_file_encoding="utf-8"
|
||||
)
|
||||
settings = Settings()
|
||||
|
||||
# 全局标识
|
||||
global_vars = GlobalVar()
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ class LogSettings(BaseSettings):
|
||||
|
||||
class Config:
|
||||
case_sensitive = True
|
||||
env_file = SystemUtils.get_config_path() / "app.env"
|
||||
env_file = SystemUtils.get_env_path()
|
||||
env_file_encoding = "utf-8"
|
||||
|
||||
|
||||
|
||||
@@ -487,3 +487,10 @@ class SystemUtils:
|
||||
return Path(sys.executable).parent / "config"
|
||||
else:
|
||||
return Path(__file__).parents[2] / "config"
|
||||
|
||||
@staticmethod
|
||||
def get_env_path() -> Path:
|
||||
"""
|
||||
获取配置路径
|
||||
"""
|
||||
return SystemUtils.get_config_path() / "app.env"
|
||||
|
||||
Reference in New Issue
Block a user