Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions __tests__/ut/commands/modelService_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ describe('ModelService', () => {
it('should successfully remove model', async () => {
const name = 'test-project$test-env$test-function';
const params = {
nasMountPoints: [{ mountDir: '/mnt/test' }],
nasMountPoints: [{ mountDir: '/mnt/test', serverAddr: 'xxxxx:/test' }],
ossMountPoints: [],
role: 'acs:ram::123456789:role/aliyundevsdefaultrole',
region: 'cn-hangzhou',
Expand All @@ -350,7 +350,7 @@ describe('ModelService', () => {
it('should handle remove error', async () => {
const name = 'test-project$test-env$test-function';
const params = {
nasMountPoints: [{ mountDir: '/mnt/test' }],
nasMountPoints: [{ mountDir: '/mnt/test', serverAddr: 'xxxxx:/test' }],
ossMountPoints: [],
role: 'acs:ram::123456789:role/aliyundevsdefaultrole',
region: 'cn-hangzhou',
Expand All @@ -374,7 +374,7 @@ describe('ModelService', () => {
it('should handle remove error with NoSuchFileError', async () => {
const name = 'test-project$test-env$test-function';
const params = {
nasMountPoints: [{ mountDir: '/mnt/test' }],
nasMountPoints: [{ mountDir: '/mnt/test', serverAddr: 'xxxxx:/test' }],
ossMountPoints: [],
role: 'acs:ram::123456789:role/aliyundevsdefaultrole',
region: 'cn-hangzhou',
Expand Down
17 changes: 17 additions & 0 deletions src/subCommands/model/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,23 @@ export class ModelService {

const processedOssMountPoints = extractOssMountDir(ossMountPoints);

if (
storage === 'oss' &&
processedOssMountPoints[0] &&
(!processedOssMountPoints[0].bucketPath || processedOssMountPoints[0].bucketPath === '/')
) {
throw new Error(
'The current deleted directory is the OSS root directory. To delete the current model, please go to the OSS console to delete the model.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

之前那个 ignore remove 的环境变量似乎没有生效啊

);
}

const nasPath = nasMountPoints[0]?.serverAddr?.split(':')[1];

if (storage === 'nas' && nasMountPoints[0] && nasPath?.trim() === '/') {
throw new Error(
'The current deleted directory is the NAS root directory. To delete the current model, please go to the NAS console to delete the model.',
);
}
const fileManagerRmRequest = new $Dev20230714.FileManagerRmRequest({
filepath:
storage === 'nas' ? nasMountPoints[0]?.mountDir : processedOssMountPoints[0]?.mountDir,
Expand Down
Loading