Skip to content

Commit

Permalink
fix(wopan): missing familyID on mkdir (close #4927)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Aug 4, 2023
1 parent c4f901b commit 6c1c7e5
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions drivers/wopan/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package template
import (
"context"
"fmt"
"strconv"

"github.com/Xhofe/wopan-sdk-go"
"github.com/alist-org/alist/v3/internal/driver"
Expand All @@ -15,7 +16,8 @@ import (
type Wopan struct {
model.Storage
Addition
client *wopan.WoClient
client *wopan.WoClient
defaultFamilyID string
}

func (d *Wopan) Config() driver.Config {
Expand All @@ -34,6 +36,11 @@ func (d *Wopan) Init(ctx context.Context) error {
d.RefreshToken = refreshToken
op.MustSaveDriverStorage(d)
})
fml, err := d.client.FamilyUserCurrentEncode()
if err != nil {
return err
}
d.defaultFamilyID = strconv.Itoa(fml.DefaultHomeId)
return d.client.InitData()
}

Expand Down Expand Up @@ -81,7 +88,11 @@ func (d *Wopan) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (
}

func (d *Wopan) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error {
_, err := d.client.CreateDirectory(d.getSpaceType(), parentDir.GetID(), dirName, d.FamilyID, func(req *resty.Request) {
familyID := d.FamilyID
if familyID == "" {
familyID = d.defaultFamilyID
}
_, err := d.client.CreateDirectory(d.getSpaceType(), parentDir.GetID(), dirName, familyID, func(req *resty.Request) {
req.SetContext(ctx)
})
return err
Expand Down

0 comments on commit 6c1c7e5

Please sign in to comment.