fix(onlyoffice): 修复云端台账保存与备份重开
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
"""Abort a deployment when ONLYOFFICE still has live collaborative editors."""
|
||||
|
||||
import asyncio
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(PROJECT_ROOT))
|
||||
|
||||
from fastapi import HTTPException # noqa: E402
|
||||
|
||||
from app.core.config import settings # noqa: E402
|
||||
from app.db.session import SessionLocal # noqa: E402
|
||||
from app.services.onlyoffice_collaboration_service import list_live_editing_sessions # noqa: E402
|
||||
|
||||
|
||||
async def async_main() -> int:
|
||||
if not settings.ONLYOFFICE_ENABLED:
|
||||
print("ONLYOFFICE 未启用,跳过在线编辑会话检查")
|
||||
return 0
|
||||
try:
|
||||
async with SessionLocal() as db:
|
||||
active = await list_live_editing_sessions(db)
|
||||
except HTTPException as exc:
|
||||
print(f"无法确认 ONLYOFFICE 在线编辑状态:{exc.detail}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
if not active:
|
||||
print("未检测到 ONLYOFFICE 在线编辑者")
|
||||
return 0
|
||||
print("检测到仍在进行的 ONLYOFFICE 在线编辑,会中止本次部署:", file=sys.stderr)
|
||||
for title, count in active:
|
||||
print(f"- {title}:{count} 人在线", file=sys.stderr)
|
||||
print("请通知用户退出编辑器,等待最终保存完成后重新执行部署。", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
|
||||
def main() -> None:
|
||||
raise SystemExit(asyncio.run(async_main()))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user