fix: create_project 设置 workspace_dir + org_id 并创建项目专属目录
根因:_t_create_project 未设置 workspace_dir,导致 _resolve_workspace 回退到 ~/pipeline_ws/default,所有项目共用同一目录,设计文档互相覆盖;前端 get_workspace_path 又回退到 /d/pipeline/workspaces/<org>/<项目名>,两处不一致导致工作空间浏览器显示'不可用'而文档实际写在 default
This commit is contained in:
parent
e479b347bd
commit
802143b723
@ -651,17 +651,33 @@ class AgentExecutor:
|
||||
return f"未找到项目: {name}"
|
||||
|
||||
async def _t_create_project(self, sor, p, pid):
|
||||
import os
|
||||
from appPublic.uniqueID import getID
|
||||
from .workspace import WORKSPACE_BASE
|
||||
|
||||
name = p.get("name", "").strip()
|
||||
desc = p.get("description", "")
|
||||
if not name:
|
||||
return "需要项目名称"
|
||||
|
||||
# 查当前用户 org_id(工作空间按 org 隔离)
|
||||
org_id = "0"
|
||||
if self.user_id:
|
||||
_u = await sor.sqlExe(
|
||||
"SELECT orgid FROM users WHERE id=${u}$ LIMIT 1", {"u": self.user_id})
|
||||
if _u:
|
||||
org_id = getattr(_u[0], "orgid", "0") or "0"
|
||||
|
||||
# 项目专属工作空间目录(与 workspace.py get_workspace_path 回退逻辑一致)
|
||||
# 不设置 workspace_dir 会导致 _resolve_workspace 回退到 ~/pipeline_ws/default,
|
||||
# 所有项目共用同一目录,设计文档/代码互相覆盖。
|
||||
workspace_dir = os.path.join(WORKSPACE_BASE, str(org_id), name)
|
||||
os.makedirs(workspace_dir, exist_ok=True)
|
||||
|
||||
pid_val = getID()
|
||||
await sor.C("sd_projects", {
|
||||
"id": pid_val, "name": name, "description": desc,
|
||||
"status": "active",
|
||||
"status": "active", "org_id": org_id, "workspace_dir": workspace_dir,
|
||||
})
|
||||
await sor.C("sd_iterations", {
|
||||
"id": getID(), "project_id": pid_val,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user