@@ -1379,14 +1379,6 @@ func (d *Yun139) dirPath(dir model.Obj) string {
13791379 return path .Join (p , id )
13801380}
13811381
1382- // helper to strip "root:/" or "root:" prefix
1383- func stripRootPath (s string ) string {
1384- s = strings .TrimSpace (s )
1385- s = strings .TrimPrefix (s , "root:/" )
1386- s = strings .TrimPrefix (s , "root:" )
1387- return s
1388- }
1389-
13901382// getFamilyRootPath 查询 family 的上层 path(data.path)
13911383// 返回值已去除前缀 "root:/"(或 "root:"),直接返回纯 ID 或 path 部分,便于持久化为 RootFolderID。
13921384func (d * Yun139 ) getFamilyRootPath (cloudID string ) (string , error ) {
@@ -1417,14 +1409,21 @@ func (d *Yun139) getFamilyRootPath(cloudID string) (string, error) {
14171409 if dataObj == nil {
14181410 return "" , fmt .Errorf ("invalid family response data" )
14191411 }
1412+ // helper to strip "root:/" or "root:" prefix
1413+ stripRoot := func (s string ) string {
1414+ s = strings .TrimSpace (s )
1415+ s = strings .TrimPrefix (s , "root:/" )
1416+ s = strings .TrimPrefix (s , "root:" )
1417+ return s
1418+ }
14201419 if p , ok := dataObj ["path" ].(string ); ok && p != "" {
1421- return stripRootPath (p ), nil
1420+ return stripRoot (p ), nil
14221421 }
14231422 // 回退:有时 path 在 cloudCatalogList.catalogList 中
14241423 if cl , ok := dataObj ["cloudCatalogList" ].([]interface {}); ok && len (cl ) > 0 {
14251424 if first , ok := cl [0 ].(map [string ]interface {}); ok {
14261425 if p , ok := first ["path" ].(string ); ok && p != "" {
1427- return stripRootPath (p ), nil
1426+ return stripRoot (p ), nil
14281427 }
14291428 }
14301429 }
0 commit comments