workspace: use ~/pipeline_ws as default (NFS persistent)

This commit is contained in:
ymq 2026-08-08 11:27:02 +08:00
parent 83ad318801
commit a897182404

View File

@ -129,24 +129,17 @@ def _get_db():
def _resolve_workspace(workspace_dir): def _resolve_workspace(workspace_dir):
"""解析工作目录,如果不可写则回退到 pipeline 用户可写的 /tmp/pipeline_ws。确保目录存在。""" """解析工作目录,如果不可写则回退到 ~/pipeline_ws。确保目录存在。"""
if not workspace_dir: if not workspace_dir:
workspace_dir = '/tmp/pipeline_ws/default' workspace_dir = os.path.expanduser('~/pipeline_ws/default')
# 检测是否可写
try: try:
parent = os.path.dirname(workspace_dir) parent = os.path.dirname(workspace_dir)
if parent and not os.access(parent, os.W_OK): if parent and not os.access(parent, os.W_OK):
# 回退到 pipeline 用户可写的目录
proj_name = os.path.basename(workspace_dir) proj_name = os.path.basename(workspace_dir)
workspace_dir = f'/tmp/pipeline_ws/{proj_name}' workspace_dir = os.path.expanduser(f'~/pipeline_ws/{proj_name}')
except Exception: except Exception:
workspace_dir = f'/tmp/pipeline_ws/{os.path.basename(workspace_dir) or "default"}' workspace_dir = os.path.expanduser(f'~/pipeline_ws/{os.path.basename(workspace_dir) or "default"}')
# 确保目录存在,设宽松权限
os.makedirs(workspace_dir, exist_ok=True) os.makedirs(workspace_dir, exist_ok=True)
try:
os.chmod(workspace_dir, 0o777)
except Exception:
pass
return workspace_dir return workspace_dir