pipeline-sdlc/wwwroot/api/workspace_delete.dspy
ymq 0c66bdee81 fix(workspace): 工作控件产线隔离——弹窗与9个子端点全部按产线过滤
- workspace_popup 把 pipeline_id 透传给树/文件/查看/编辑/删除子端点
- 9个子端点 get_project_dir→get_project_dir_pl(跨产线项目视为无项目)
- 开发驾驶舱工作空间按钮补传 pipeline_id=sdlc_general
- 修复:会话绑投标项目时开发驾驶舱工作空间直接打开投标项目目录(已实测复现)
2026-08-31 16:54:08 +08:00

41 lines
1.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# workspace_delete.dspy - 删除工作空间文件
import os
file_id = (params_kw or {}).get('id', '').strip()
uid = await get_user()
if not uid:
uid = 'user-01'
session_id = (params_kw or {}).get('session_id', '') or ''
pipeline_id = (params_kw or {}).get('pipeline_id', '') or ''
dbname = get_module_dbname('pipeline-sdlc')
async with DBPools().sqlorContext(dbname) as sor:
# 产线隔离:跨产线项目视为无项目(与弹窗入口一致,防绕过)
project_dir, _ = await get_project_dir_pl(sor, uid, session_id, pipeline_id)
space_dir, _ = await get_space_dir(sor, uid, session_id)
if not file_id or file_id == '__root__':
return {"status": "error", "message": "不能删除根目录"}
full_path = resolve_workspace_path(project_dir, space_dir, file_id)
# 防止路径穿越确保最终路径在机构工作空间space_dir
real_ws = os.path.realpath(space_dir)
real_full = os.path.realpath(full_path)
if not real_full.startswith(real_ws + os.sep):
return {"status": "error", "message": "非法路径"}
if not os.path.isfile(full_path):
return {"status": "error", "message": "文件不存在: " + file_id}
try:
os.remove(full_path)
except Exception as e:
return {"status": "error", "message": "删除失败: " + str(e)}
return {"status": "ok", "message": "已删除: " + os.path.basename(full_path)}