mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 15:38:19 +08:00
fix(plugin): 收敛市场安装与运行态错误处理 (#6470)
This commit is contained in:
@@ -23,11 +23,12 @@ from app.schemas.exception import (
|
||||
PersistenceUnavailableError,
|
||||
PluginMutationRejectedError,
|
||||
)
|
||||
from app.schemas.plugin import PluginRuntimeStatus
|
||||
|
||||
InstalledPluginsReader = Callable[[], list[str]]
|
||||
PluginIdsProvider = Callable[[], list[str]]
|
||||
InstallReporter = Callable[[str, str | None], Awaitable[object]]
|
||||
PluginReloader = Callable[[str], Awaitable[object]]
|
||||
PluginReloader = Callable[[str], Awaitable[PluginRuntimeStatus]]
|
||||
PluginRegistrationRefresher = Callable[[str], Awaitable[object]]
|
||||
PluginMutationAdmission = Callable[[str], ContextManager[None]]
|
||||
PluginPackageWriteGuard = Callable[[str], ContextManager[None]]
|
||||
@@ -380,7 +381,7 @@ class PluginInstallCommand:
|
||||
|
||||
state.stage = "runtime_reload"
|
||||
state.runtime_touched = True
|
||||
await self.__await_side_effect(self.__target_reloader(plugin_id))
|
||||
await self.__reload_active(plugin_id)
|
||||
state.stage = "registration_refresh"
|
||||
state.registrations_touched = True
|
||||
await self.__await_side_effect(
|
||||
@@ -511,7 +512,7 @@ class PluginInstallCommand:
|
||||
"""刷新已经提交且载荷事实未变化的插件运行态。"""
|
||||
failure_stage = "runtime_reload"
|
||||
try:
|
||||
await self.__await_side_effect(self.__target_reloader(plugin_id))
|
||||
await self.__reload_active(plugin_id)
|
||||
failure_stage = "registration_refresh"
|
||||
await self.__await_side_effect(
|
||||
self.__registration_refresher(plugin_id)
|
||||
@@ -542,6 +543,14 @@ class PluginInstallCommand:
|
||||
report_error=report_error,
|
||||
)
|
||||
|
||||
async def __reload_active(self, plugin_id: str) -> None:
|
||||
"""重载只有进入 ACTIVE 才能作为安装或刷新成功继续提交。"""
|
||||
runtime_status = await self.__await_side_effect(
|
||||
self.__target_reloader(plugin_id)
|
||||
)
|
||||
if runtime_status is not PluginRuntimeStatus.ACTIVE:
|
||||
raise RuntimeError("插件加载失败,请查看插件日志")
|
||||
|
||||
async def __finish_committed(self, state: _InstallState) -> str:
|
||||
"""幂等清理 COMMITTED 事务;失败时保留 journal 供启动回放。"""
|
||||
try:
|
||||
|
||||
@@ -53,7 +53,7 @@ class PluginCandidateInventoryReader:
|
||||
local_candidate_loader: LocalCandidateLoader | None = None,
|
||||
async_market_loader: AsyncMarketLoader | None = None,
|
||||
generations: Sequence[str] = PLUGIN_V3_GENERATIONS,
|
||||
max_concurrency: int = 12,
|
||||
max_concurrency: int = 24,
|
||||
) -> None:
|
||||
"""保存读取端口,并限制异步市场请求的进程内并发。"""
|
||||
normalized_generations = tuple(
|
||||
|
||||
@@ -689,7 +689,7 @@ def list_effective_online_candidates(
|
||||
plugin_id: str,
|
||||
generations: Sequence[str],
|
||||
) -> tuple[PluginMarketCandidate, ...]:
|
||||
"""按来源列出当前运行代际实际可安装的最高版本候选。"""
|
||||
"""按来源列出当前运行代际实际可安装的最高版本候选,官方来源始终置顶。"""
|
||||
generation_order = _normalize_generation_order(generations)
|
||||
grouped: dict[
|
||||
tuple[TrustedPluginSourceType, str],
|
||||
@@ -706,6 +706,10 @@ def list_effective_online_candidates(
|
||||
selected_candidate = _select_best(candidates, generation_order)
|
||||
if isinstance(selected_candidate, PluginMarketCandidate):
|
||||
selected.append(selected_candidate)
|
||||
selected.sort(
|
||||
key=lambda candidate: candidate.source_type
|
||||
is not TrustedPluginSourceType.OFFICIAL
|
||||
)
|
||||
return tuple(selected)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user