feat(plugin): 建立可信来源准入与安装恢复 (#6462)

This commit is contained in:
InfinityPacer
2026-08-26 07:52:00 +08:00
committed by GitHub
parent 3272f72823
commit 71db425c07
58 changed files with 11471 additions and 1493 deletions
+51
View File
@@ -7,6 +7,9 @@ from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm import Session
from app.application.plugin.identity import (
BindLocalPluginIdentityCommand,
BindOnlinePluginIdentityCommand,
ChangePluginIdentitySourceCommand,
PluginBindingBasis,
PluginIdentity,
PluginIdentityConflictError,
@@ -143,3 +146,51 @@ class TransactionalPluginIdentityStore:
).execute(identity, expected_revision=expected_revision)
finally:
session.close()
def change_source(
self,
identity: PluginIdentity,
*,
expected_revision: int,
) -> PluginIdentity:
"""在独占事务内提交明确的在线来源转换。"""
session = self._session_factory()
try:
return ChangePluginIdentitySourceCommand(
repository=_SqlAlchemyIdentityRepository(session),
unit_of_work=SqlAlchemyUnitOfWork(session),
).execute(identity, expected_revision=expected_revision)
finally:
session.close()
def bind_local(
self,
identity: PluginIdentity,
*,
expected_revision: int,
) -> PluginIdentity:
"""在独占事务内提交 legacy_unbound 到 local_only 的转换。"""
session = self._session_factory()
try:
return BindLocalPluginIdentityCommand(
repository=_SqlAlchemyIdentityRepository(session),
unit_of_work=SqlAlchemyUnitOfWork(session),
).execute(identity, expected_revision=expected_revision)
finally:
session.close()
def bind_online(
self,
identity: PluginIdentity,
*,
expected_revision: int,
) -> PluginIdentity:
"""在独占事务内提交未绑定身份的首次在线来源绑定。"""
session = self._session_factory()
try:
return BindOnlinePluginIdentityCommand(
repository=_SqlAlchemyIdentityRepository(session),
unit_of_work=SqlAlchemyUnitOfWork(session),
).execute(identity, expected_revision=expected_revision)
finally:
session.close()