Skip to content

Commit cc5172e

Browse files
authored
fix(weiyun): update sdk and support getDetails (#1845)
1 parent a32ae97 commit cc5172e

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

drivers/weiyun/driver.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
2121
"github.com/avast/retry-go"
2222
weiyunsdkgo "github.com/foxxorcat/weiyun-sdk-go"
23+
"github.com/go-resty/resty/v2"
2324
)
2425

2526
type WeiYun struct {
@@ -67,7 +68,7 @@ func (d *WeiYun) Init(ctx context.Context) error {
6768
})
6869

6970
// qqCookie保活
70-
if d.client.LoginType() == 1 {
71+
if d.client.LoginType() == weiyunsdkgo.AccountTypeQQ || d.client.LoginType() == weiyunsdkgo.AccountTypeQQOpenID {
7172
d.cron = cron.NewCron(time.Minute * 5)
7273
d.cron.Do(func() {
7374
_ = d.client.KeepAlive()
@@ -391,6 +392,19 @@ func (d *WeiYun) Put(ctx context.Context, dstDir model.Obj, stream model.FileStr
391392
}, nil
392393
}
393394

395+
func (d *WeiYun) GetDetails(ctx context.Context) (*model.StorageDetails, error) {
396+
info, err := d.client.DiskUserInfoGet(func(request *resty.Request) {
397+
request.SetContext(ctx)
398+
})
399+
if err != nil {
400+
return nil, err
401+
}
402+
403+
return &model.StorageDetails{
404+
DiskUsage: driver.DiskUsageFromUsedAndTotal(uint64(info.UsedSpace), uint64(info.TotalSpace)),
405+
}, nil
406+
}
407+
394408
// func (d *WeiYun) Other(ctx context.Context, args model.OtherArgs) (interface{}, error) {
395409
// return nil, errs.NotSupport
396410
// }
@@ -405,3 +419,4 @@ var _ driver.Remove = (*WeiYun)(nil)
405419

406420
var _ driver.PutResult = (*WeiYun)(nil)
407421
var _ driver.RenameResult = (*WeiYun)(nil)
422+
var _ driver.WithDetails = (*WeiYun)(nil)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ require (
3434
github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564
3535
github.com/fclairamb/ftpserverlib v0.26.1-0.20250709223522-4a925d79caf6
3636
github.com/foxxorcat/mopan-sdk-go v0.1.6
37-
github.com/foxxorcat/weiyun-sdk-go v0.1.3
37+
github.com/foxxorcat/weiyun-sdk-go v0.1.4
3838
github.com/gin-contrib/cors v1.7.6
3939
github.com/gin-gonic/gin v1.10.1
4040
github.com/go-resty/resty/v2 v2.16.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2
285285
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
286286
github.com/foxxorcat/mopan-sdk-go v0.1.6 h1:6J37oI4wMZLj8EPgSCcSTTIbnI5D6RCNW/srX8vQd1Y=
287287
github.com/foxxorcat/mopan-sdk-go v0.1.6/go.mod h1:UaY6D88yBXWGrcu/PcyLWyL4lzrk5pSxSABPHftOvxs=
288-
github.com/foxxorcat/weiyun-sdk-go v0.1.3 h1:I5c5nfGErhq9DBumyjCVCggRA74jhgriMqRRFu5jeeY=
289-
github.com/foxxorcat/weiyun-sdk-go v0.1.3/go.mod h1:TPxzN0d2PahweUEHlOBWlwZSA+rELSUlGYMWgXRn9ps=
288+
github.com/foxxorcat/weiyun-sdk-go v0.1.4 h1:X2tFvdqikkJ7awCBbMH7XXk7+uQoJlQksJz9CUU6ZgA=
289+
github.com/foxxorcat/weiyun-sdk-go v0.1.4/go.mod h1:TPxzN0d2PahweUEHlOBWlwZSA+rELSUlGYMWgXRn9ps=
290290
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
291291
github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM=
292292
github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=

0 commit comments

Comments
 (0)