Skip to content

Commit c9a01e5

Browse files
author
高魏洪
committed
fix: Remove root directory error
1 parent 86ecf29 commit c9a01e5

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

__tests__/ut/commands/modelService_test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ describe('ModelService', () => {
329329
it('should successfully remove model', async () => {
330330
const name = 'test-project$test-env$test-function';
331331
const params = {
332-
nasMountPoints: [{ mountDir: '/mnt/test' }],
332+
nasMountPoints: [{ mountDir: '/mnt/test', serverAddr: 'xxxxx:/test' }],
333333
ossMountPoints: [],
334334
role: 'acs:ram::123456789:role/aliyundevsdefaultrole',
335335
region: 'cn-hangzhou',
@@ -350,7 +350,7 @@ describe('ModelService', () => {
350350
it('should handle remove error', async () => {
351351
const name = 'test-project$test-env$test-function';
352352
const params = {
353-
nasMountPoints: [{ mountDir: '/mnt/test' }],
353+
nasMountPoints: [{ mountDir: '/mnt/test', serverAddr: 'xxxxx:/test' }],
354354
ossMountPoints: [],
355355
role: 'acs:ram::123456789:role/aliyundevsdefaultrole',
356356
region: 'cn-hangzhou',
@@ -374,7 +374,7 @@ describe('ModelService', () => {
374374
it('should handle remove error with NoSuchFileError', async () => {
375375
const name = 'test-project$test-env$test-function';
376376
const params = {
377-
nasMountPoints: [{ mountDir: '/mnt/test' }],
377+
nasMountPoints: [{ mountDir: '/mnt/test', serverAddr: 'xxxxx:/test' }],
378378
ossMountPoints: [],
379379
role: 'acs:ram::123456789:role/aliyundevsdefaultrole',
380380
region: 'cn-hangzhou',

src/subCommands/model/model.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,23 @@ export class ModelService {
107107

108108
const processedOssMountPoints = extractOssMountDir(ossMountPoints);
109109

110+
if (
111+
storage === 'oss' &&
112+
processedOssMountPoints[0] &&
113+
(!processedOssMountPoints[0].bucketPath || processedOssMountPoints[0].bucketPath === '/')
114+
) {
115+
throw new Error(
116+
'The current deleted directory is the OSS root directory. To delete the current model, please go to the OSS console to delete the model.',
117+
);
118+
}
119+
120+
const nasPath = nasMountPoints[0].serverAddr.split(':')[1];
121+
122+
if (storage === 'nas' && nasMountPoints[0] && nasPath.trim() === '/') {
123+
throw new Error(
124+
'The current deleted directory is the NAS root directory. To delete the current model, please go to the NAS console to delete the model.',
125+
);
126+
}
110127
const fileManagerRmRequest = new $Dev20230714.FileManagerRmRequest({
111128
filepath:
112129
storage === 'nas' ? nasMountPoints[0]?.mountDir : processedOssMountPoints[0]?.mountDir,

0 commit comments

Comments
 (0)