fix: 标书合成失败不回退/tmp——输出文件必须落项目空间,工作目录解析失败直接中止合成

This commit is contained in:
yumoqing 2026-09-02 11:56:49 +08:00
parent b7bbee6563
commit 1eafd7b1c3

View File

@ -23,18 +23,16 @@ async def _workspace_dir(sor, project_id):
不走 get_workspace_dir(那个依赖会话当前项目),角色 agent 场景下按项目自身字段解析。
旧实现自行拼 {base}/{org}/{pipeline_id}/{项目名}(旧平铺口径)导致与项目目录错位,
2026-09-01 收敛到引擎统一函数根治。
铁律(输出文件必须在项目空间内):解析失败绝不回退 /tmp——
标书是交付件,写到项目外就违反"输出文件必须在项目空间内"。宁可合成失败。
"""
try:
from pipeline_service.workspace import get_project_dir_by_id
pdir, _ = await get_project_dir_by_id(sor, project_id)
if pdir:
os.makedirs(pdir, exist_ok=True)
return pdir
except Exception as e:
logger.warning("workspace resolve failed: %s", str(e)[:120])
d = os.path.join("/tmp", "pipeline_bidding", project_id)
os.makedirs(d, exist_ok=True)
return d
from pipeline_service.workspace import get_project_dir_by_id
pdir, _ = await get_project_dir_by_id(sor, project_id)
if pdir:
os.makedirs(pdir, exist_ok=True)
return pdir
return ''
def _write_docx(path, title, subtitle, chapters):
@ -130,6 +128,8 @@ async def compose_bid(project_id, doc_name="", who=None, agent_id=None, task_id=
ver = to_int(getattr(vrec[0], "v", 0) if vrec else 0) + 1
ws = await _workspace_dir(sor, project_id)
if not ws:
return False, "无法解析项目工作目录(输出文件必须落项目空间内,已中止合成)"
title = doc_name or ("%s 投标文件" % (tender.get("title") or proj.get("name") or "项目"))
subtitle = "投标人:(本单位)  招标编号:%s" % (tender.get("tender_no") or "-")