@@ -3,6 +3,7 @@ package LenovoNasShare
33import (
44 "context"
55 "net/http"
6+ "strings"
67 "time"
78
89 "github.com/go-resty/resty/v2"
@@ -32,6 +33,10 @@ func (d *LenovoNasShare) Init(ctx context.Context) error {
3233 if err := d .getStoken (); err != nil {
3334 return err
3435 }
36+ if ! d .ShowRootFolder && d .RootFolderPath == "" {
37+ list , _ := d .List (ctx , File {}, model.ListArgs {})
38+ d .RootFolderPath = list [0 ].GetPath ()
39+ }
3540 return nil
3641}
3742
@@ -43,19 +48,26 @@ func (d *LenovoNasShare) List(ctx context.Context, dir model.Obj, args model.Lis
4348 d .checkStoken () // 检查stoken是否过期
4449 files := make ([]File , 0 )
4550
51+ path := dir .GetPath ()
52+ if path == "" && ! d .ShowRootFolder && d .RootFolderPath != "" {
53+ path = d .RootFolderPath
54+ }
55+
4656 var resp Files
4757 query := map [string ]string {
4858 "code" : d .ShareId ,
4959 "num" : "5000" ,
5060 "stoken" : d .stoken ,
51- "path" : dir . GetPath () ,
61+ "path" : path ,
5262 }
5363 _ , err := d .request (d .Host + "/oneproxy/api/share/v1/files" , http .MethodGet , func (req * resty.Request ) {
5464 req .SetQueryParams (query )
5565 }, & resp )
66+
5667 if err != nil {
5768 return nil , err
5869 }
70+
5971 files = append (files , resp .Data .List ... )
6072
6173 return utils .SliceConvert (files , func (src File ) (model.Obj , error ) {
@@ -73,6 +85,10 @@ func (d *LenovoNasShare) getStoken() error { // 获取stoken
7385 if d .Host == "" {
7486 d .Host = "https://siot-share.lenovo.com.cn"
7587 }
88+
89+ parts := strings .Split (d .ShareId , "/" )
90+ d .ShareId = parts [len (parts )- 1 ]
91+
7692 query := map [string ]string {
7793 "code" : d .ShareId ,
7894 "password" : d .SharePwd ,
0 commit comments