@@ -41,7 +41,11 @@ const (
4141
4242// do others that not defined in Driver interface
4343func (d * Yun139 ) isFamily () bool {
44- return d .Type == "family"
44+ return d .Type == MetaFamily
45+ }
46+
47+ func (d * Yun139 ) isGroup () bool {
48+ return d .Type == MetaGroup
4549}
4650
4751func encodeURIComponent (str string ) string {
@@ -353,6 +357,10 @@ func (d *Yun139) familyGetFiles(catalogID string) ([]model.Obj, error) {
353357 }
354358 // 返回的是完整的Path: root:/<UserRootID>/<CatalogID>/.../<CatalogID>
355359 path := resp .Data .Path
360+ if catalogID == d .RootFolderID {
361+ path = ensureRootPath (d .RootPath )
362+ d .RootPath = path
363+ }
356364 for _ , catalog := range resp .Data .CloudCatalogList {
357365 f := model.Object {
358366 ID : catalog .CatalogID ,
@@ -1363,8 +1371,25 @@ func (d *Yun139) getGroupRootByCloudID(cloudID string) (string, error) {
13631371 return "" , fmt .Errorf ("no root found in group response" )
13641372}
13651373
1374+ // helper to strip "root:/" or "root:" prefix
1375+ func stripRootPath (s string ) string {
1376+ s = strings .TrimSpace (s )
1377+ s = strings .TrimPrefix (s , "root:/" )
1378+ s = strings .TrimPrefix (s , "root:" )
1379+ return s
1380+ }
1381+
1382+ // helper to ensure "root:/" prefix
1383+ func ensureRootPath (s string ) string {
1384+ s = strings .TrimSpace (s )
1385+ if ! strings .HasPrefix (s , "root:" ) {
1386+ s = "root:/" + s
1387+ }
1388+ return s
1389+ }
1390+
13661391// getFamilyRootPath 查询 family 的上层 path(data.path)
1367- // 返回值为完整Path
1392+ // 返回值已去除前缀 "root:/"(或 "root:"),直接返回纯 ID 或 path 部分,便于持久化为 RootFolderID。
13681393func (d * Yun139 ) getFamilyRootPath (cloudID string ) (string , error ) {
13691394 // 使用 v1.2 接口(代码日志中已有该请求),pageSize 取 1 足够获取 path 字段
13701395 pathname := "/orchestration/familyCloud-rebuild/content/v1.2/queryContentList"
@@ -1394,13 +1419,13 @@ func (d *Yun139) getFamilyRootPath(cloudID string) (string, error) {
13941419 return "" , fmt .Errorf ("invalid family response data" )
13951420 }
13961421 if p , ok := dataObj ["path" ].(string ); ok && p != "" {
1397- return p , nil
1422+ return stripRootPath ( p ) , nil
13981423 }
13991424 // 回退:有时 path 在 cloudCatalogList.catalogList 中
14001425 if cl , ok := dataObj ["cloudCatalogList" ].([]interface {}); ok && len (cl ) > 0 {
14011426 if first , ok := cl [0 ].(map [string ]interface {}); ok {
14021427 if p , ok := first ["path" ].(string ); ok && p != "" {
1403- return p , nil
1428+ return stripRootPath ( p ) , nil
14041429 }
14051430 }
14061431 }
0 commit comments