Skip to content

Commit

Permalink
fix: AI应用的工作目录和挂载点重复时报错 (#1395)
Browse files Browse the repository at this point in the history
## 之前挂载点和工作目录重复时会报错:

![img_v3_02dj_fe4f50a9-335e-4a1b-a654-f7d55e7fdb8g](https://github.com/user-attachments/assets/32d214c6-94eb-451f-91db-132552e0afb4)
## 因为工作目录一定会被挂载,该目录再次添加作为挂载点会有问题
## 改动后前端不允许用户添加和工作目录一样的挂载点目录,提示用户:该路径已指定为工作目录,无需再设置为挂载点

![image](https://github.com/user-attachments/assets/0b08bacb-b65b-4f9d-9c21-d35b5a4d4255)
  • Loading branch information
OYX-1 authored Aug 14, 2024
1 parent e776999 commit 5ba5ebb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/strange-lamps-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@scow/ai": patch
---

修复 AI 应用的工作目录和挂载点重复时报错
13 changes: 13 additions & 0 deletions apps/ai/src/app/(auth)/jobs/[clusterId]/LaunchAppForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,13 @@ export const LaunchAppForm = (props: Props) => {
name={["customFields", item.name]}
rules={rules}
initialValue={initialValue}
{...(item.name === "workingDir" ? {
tooltip: (
<>
<span>工作目录的路径会自动添加为挂载点</span>
</>
),
} : {})}
>
{inputItem}
</Form.Item>
Expand Down Expand Up @@ -748,6 +755,12 @@ export const LaunchAppForm = (props: Props) => {
if (otherMountPoints.includes(currentValueNormalized)) {
return Promise.reject(new Error("挂载点地址不能重复"));
}

const workingDirectory = form.getFieldValue("customFields").workingDir?.toString();
if (workingDirectory && workingDirectory.replace(/\/+$/, "") === currentValueNormalized) {
return Promise.reject(new Error("该路径已指定为工作目录,无需再设置为挂载点"));
}

return Promise.resolve();
},
}),
Expand Down

0 comments on commit 5ba5ebb

Please sign in to comment.