mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
refactor(database): isolate configuration transactions
This commit is contained in:
@@ -874,7 +874,10 @@ async def save_plugin_folders(
|
||||
保存插件文件夹分组配置
|
||||
"""
|
||||
try:
|
||||
get_configured_system_config().set(SystemConfigKey.PluginFolders, folders)
|
||||
await get_configured_system_config().async_set(
|
||||
SystemConfigKey.PluginFolders,
|
||||
folders,
|
||||
)
|
||||
return _SchemaResponse(success=True)
|
||||
except Exception as e:
|
||||
logger.error(f"[文件夹API] 保存文件夹配置失败: {str(e)}")
|
||||
@@ -893,7 +896,10 @@ async def create_plugin_folder(
|
||||
folders = get_configured_system_config().get(SystemConfigKey.PluginFolders) or {}
|
||||
if folder_name not in folders:
|
||||
folders[folder_name] = []
|
||||
get_configured_system_config().set(SystemConfigKey.PluginFolders, folders)
|
||||
await get_configured_system_config().async_set(
|
||||
SystemConfigKey.PluginFolders,
|
||||
folders,
|
||||
)
|
||||
return _SchemaResponse(
|
||||
success=True, message=f"文件夹 '{folder_name}' 创建成功"
|
||||
)
|
||||
|
||||
@@ -188,8 +188,8 @@ async def reset(
|
||||
清空所有站点数据并重新同步CookieCloud站点信息
|
||||
"""
|
||||
result = await command.reset()
|
||||
get_configured_system_config().set(SystemConfigKey.IndexerSites, [])
|
||||
get_configured_system_config().set(SystemConfigKey.RssSites, [])
|
||||
await get_configured_system_config().async_set(SystemConfigKey.IndexerSites, [])
|
||||
await get_configured_system_config().async_set(SystemConfigKey.RssSites, [])
|
||||
# 启动定时服务
|
||||
Scheduler().start("cookiecloud", manual=True)
|
||||
# 插件站点删除
|
||||
|
||||
@@ -16,7 +16,6 @@ from app.application.security.user import UserService
|
||||
from app.api.dependencies.auth import (
|
||||
get_current_active_superuser_async,
|
||||
get_current_active_user_async,
|
||||
get_current_active_user,
|
||||
get_user_service,
|
||||
)
|
||||
from app.application.security.userconfig import get_configured_user_configuration
|
||||
@@ -140,7 +139,10 @@ async def upload_avatar(
|
||||
summary="查询用户配置",
|
||||
response_model=_SchemaResponse[_SchemaValueData],
|
||||
)
|
||||
def get_config(key: str, current_user: Any = Depends(get_current_active_user)):
|
||||
async def get_config(
|
||||
key: str,
|
||||
current_user: Any = Depends(get_current_active_user_async),
|
||||
):
|
||||
"""
|
||||
查询用户配置
|
||||
"""
|
||||
@@ -149,15 +151,15 @@ def get_config(key: str, current_user: Any = Depends(get_current_active_user)):
|
||||
|
||||
|
||||
@router.post("/config/{key}", summary="更新用户配置", response_model=_SchemaResponse[None])
|
||||
def set_config(
|
||||
async def set_config(
|
||||
key: str,
|
||||
value: Annotated[Union[list, dict, bool, int, str] | None, Body()] = None,
|
||||
current_user: Any = Depends(get_current_active_user),
|
||||
current_user: Any = Depends(get_current_active_user_async),
|
||||
):
|
||||
"""
|
||||
更新用户配置
|
||||
"""
|
||||
get_configured_user_configuration().set(
|
||||
await get_configured_user_configuration().async_set(
|
||||
username=current_user.name,
|
||||
key=key,
|
||||
value=value,
|
||||
|
||||
Reference in New Issue
Block a user