Skip to content

Commit db0ecab

Browse files
author
高魏洪
committed
fix: solution and path
1 parent 5e40d25 commit db0ecab

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

__tests__/ut/commands/artModelService_test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,24 +596,24 @@ describe('ArtModelService', () => {
596596

597597
it('should directly concatenate URI and path', () => {
598598
const result = (artModelService as any)._getDestinationPath(
599-
'/mnt/custom',
599+
'oss://mnt/custom',
600600
{ target: { path: 'file1.txt' } }, // 修正参数结构
601601
[{ mountDir: '/mnt/nas' }],
602602
[{ mountDir: '/mnt/oss' }],
603603
);
604604

605-
expect(result).toBe('file:///mnt/custom/file1.txt');
605+
expect(result).toBe('file://mnt/custom/file1.txt');
606606
});
607607

608608
it('should handle URI ending with slash', () => {
609609
const result = (artModelService as any)._getDestinationPath(
610-
'/mnt/custom/',
610+
'nas://mnt/custom/',
611611
{ target: { path: 'file1.txt' } }, // 修正参数结构
612612
[{ mountDir: '/mnt/nas' }],
613613
[{ mountDir: '/mnt/oss' }],
614614
);
615615

616-
expect(result).toBe('file:///mnt/custom/file1.txt');
616+
expect(result).toBe('file://mnt/custom/file1.txt');
617617
});
618618
});
619619
});

src/subCommands/model/fileManager.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,8 @@ export class ArtModelService {
414414
private _getSourcePath(file: any, sourceUri: string): string {
415415
// 会有多个文件,file.source.uri 是该文件下载源路径,sourceUri 是公共的下载源
416416
const uri = file.source.uri || sourceUri;
417-
const path = file.source?.path || '';
417+
const path =
418+
(file.source?.path.startsWith('/') ? file.source.path.slice(1) : file.source.path) || '';
418419
const validSourcePattern = /^(modelscope|oss|nas):\/\//;
419420

420421
if (validSourcePattern.test(uri)) {
@@ -435,7 +436,8 @@ export class ArtModelService {
435436
): string {
436437
// file.target.uri 多个nas或者oss挂载点时,优先判断是否有指定挂载点,否则使用默认挂载点
437438
const uri = file.target?.uri || targetUri;
438-
const path = file.target?.path || '';
439+
const path =
440+
(file.target?.path.startsWith('/') ? file.target.path.slice(1) : file.target.path) || '';
439441

440442
// 判断uri是否为nas://auto或oss://auto
441443
if (uri.startsWith('nas://auto') && nasMountPoints?.length > 0) {
@@ -450,8 +452,10 @@ export class ArtModelService {
450452
return `file://${mountDir}/${path}`;
451453
} else {
452454
// 直接拼接uri和path
453-
const normalizedUri = uri.endsWith('/') ? uri.slice(0, -1) : uri;
454-
return `file://${normalizedUri}/${path}`;
455+
let normalizedUri = uri.endsWith('/') ? uri.slice(0, -1) : uri;
456+
// nas:// 或 oss:// 前缀替换成 file://
457+
normalizedUri = normalizedUri.replace(/^(nas|oss):\/\//, 'file://');
458+
return `${normalizedUri}/${path}`;
455459
}
456460
}
457461
}

src/subCommands/model/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class Model {
5858

5959
const params = (await this.getParams()) as any;
6060
try {
61-
if (modelConfig.solution === 'funArt') {
61+
if (modelConfig.solution === 'funArt' || modelConfig.solution === 'funModel') {
6262
const modelArtService = await this.getModelArtService();
6363
await modelArtService.downloadModel(this.name, params);
6464
} else {

0 commit comments

Comments
 (0)