@@ -3,6 +3,7 @@ package _115_share
33import (
44 "context"
55
6+ "github.com/OpenListTeam/OpenList/v4/drivers/virtual_file"
67 "github.com/OpenListTeam/OpenList/v4/internal/driver"
78 "github.com/OpenListTeam/OpenList/v4/internal/errs"
89 "github.com/OpenListTeam/OpenList/v4/internal/model"
@@ -46,38 +47,54 @@ func (d *Pan115Share) Drop(ctx context.Context) error {
4647}
4748
4849func (d * Pan115Share ) List (ctx context.Context , dir model.Obj , args model.ListArgs ) ([]model.Obj , error ) {
49- if err := d .WaitLimit (ctx ); err != nil {
50- return nil , err
51- }
5250
53- files := make ([]driver115.ShareFile , 0 )
54- fileResp , err := d .client .GetShareSnap (d .ShareCode , d .ReceiveCode , dir .GetID (), driver115 .QueryLimit (int (d .PageSize )))
55- if err != nil {
56- return nil , err
57- }
58- files = append (files , fileResp .Data .List ... )
59- total := fileResp .Data .Count
60- count := len (fileResp .Data .List )
61- for total > count {
62- fileResp , err := d .client .GetShareSnap (
63- d .ShareCode , d .ReceiveCode , dir .GetID (),
64- driver115 .QueryLimit (int (d .PageSize )), driver115 .QueryOffset (count ),
65- )
51+ return virtual_file .List (d .ID , dir , func (virtualFile model.VirtualFile , dir model.Obj ) ([]model.Obj , error ) {
52+
53+ if err := d .WaitLimit (ctx ); err != nil {
54+ return nil , err
55+ }
56+
57+ parentId := ""
58+ if virDir , ok := dir .(* model.ObjVirtualDir ); ok {
59+ parentId = virDir .VirtualFile .ParentDir
60+ } else {
61+ parentId = dir .GetID ()
62+ }
63+
64+ files := make ([]driver115.ShareFile , 0 )
65+ fileResp , err := d .client .GetShareSnap (virtualFile .ShareID , virtualFile .SharePwd , parentId , driver115 .QueryLimit (int (d .PageSize )))
6666 if err != nil {
6767 return nil , err
6868 }
6969 files = append (files , fileResp .Data .List ... )
70- count += len (fileResp .Data .List )
71- }
70+ total := fileResp .Data .Count
71+ count := len (fileResp .Data .List )
72+ for total > count {
73+ fileResp , err := d .client .GetShareSnap (
74+ virtualFile .ShareID , virtualFile .SharePwd , dir .GetID (),
75+ driver115 .QueryLimit (int (d .PageSize )), driver115 .QueryOffset (count ),
76+ )
77+ if err != nil {
78+ return nil , err
79+ }
80+ files = append (files , fileResp .Data .List ... )
81+ count += len (fileResp .Data .List )
82+ }
83+
84+ return utils .SliceConvert (files , func (src driver115.ShareFile ) (model.Obj , error ) {
85+ return transFunc (dir , src )
86+ })
87+ })
7288
73- return utils .SliceConvert (files , transFunc )
7489}
7590
7691func (d * Pan115Share ) Link (ctx context.Context , file model.Obj , args model.LinkArgs ) (* model.Link , error ) {
7792 if err := d .WaitLimit (ctx ); err != nil {
7893 return nil , err
7994 }
80- downloadInfo , err := d .client .DownloadByShareCode (d .ShareCode , d .ReceiveCode , file .GetID ())
95+
96+ virtualFile := virtual_file .GetSubscription (d .ID , file .GetPath ())
97+ downloadInfo , err := d .client .DownloadByShareCode (virtualFile .ShareID , virtualFile .SharePwd , file .GetID ())
8198 if err != nil {
8299 return nil , err
83100 }
@@ -86,27 +103,31 @@ func (d *Pan115Share) Link(ctx context.Context, file model.Obj, args model.LinkA
86103}
87104
88105func (d * Pan115Share ) MakeDir (ctx context.Context , parentDir model.Obj , dirName string ) error {
89- return errs . NotSupport
106+ return virtual_file . MakeDir ( d . ID , parentDir , dirName )
90107}
91108
92109func (d * Pan115Share ) Move (ctx context.Context , srcObj , dstDir model.Obj ) error {
93- return errs . NotSupport
110+ return virtual_file . Move ( d . ID , srcObj , dstDir )
94111}
95112
96113func (d * Pan115Share ) Rename (ctx context.Context , srcObj model.Obj , newName string ) error {
97- return errs . NotSupport
114+ return virtual_file . Rename ( d . ID , srcObj , newName )
98115}
99116
100117func (d * Pan115Share ) Copy (ctx context.Context , srcObj , dstDir model.Obj ) error {
101118 return errs .NotSupport
102119}
103120
104121func (d * Pan115Share ) Remove (ctx context.Context , obj model.Obj ) error {
105- return errs . NotSupport
122+ return virtual_file . DeleteVirtualFile ( d . ID , obj )
106123}
107124
108125func (d * Pan115Share ) Put (ctx context.Context , dstDir model.Obj , stream model.FileStreamer , up driver.UpdateProgress ) error {
109126 return errs .NotSupport
110127}
111128
129+ func (d * Pan115Share ) MkdirConfig () []driver.Item {
130+ return virtual_file .GetMkdirConfig ()
131+ }
132+
112133var _ driver.Driver = (* Pan115Share )(nil )
0 commit comments