|
| 1 | +package wps |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "fmt" |
| 6 | + |
| 7 | + "github.com/OpenListTeam/OpenList/v4/internal/driver" |
| 8 | + "github.com/OpenListTeam/OpenList/v4/internal/errs" |
| 9 | + "github.com/OpenListTeam/OpenList/v4/internal/model" |
| 10 | +) |
| 11 | + |
| 12 | +type Wps struct { |
| 13 | + model.Storage |
| 14 | + Addition |
| 15 | + companyID string |
| 16 | +} |
| 17 | + |
| 18 | +func (d *Wps) Config() driver.Config { |
| 19 | + return config |
| 20 | +} |
| 21 | + |
| 22 | +func (d *Wps) GetAddition() driver.Additional { |
| 23 | + return &d.Addition |
| 24 | +} |
| 25 | + |
| 26 | +func (d *Wps) Init(ctx context.Context) error { |
| 27 | + if d.Cookie == "" { |
| 28 | + return fmt.Errorf("cookie is empty") |
| 29 | + } |
| 30 | + return d.ensureCompanyID(ctx) |
| 31 | +} |
| 32 | + |
| 33 | +func (d *Wps) Drop(ctx context.Context) error { |
| 34 | + return nil |
| 35 | +} |
| 36 | + |
| 37 | +func (d *Wps) List(ctx context.Context, dir model.Obj, _ model.ListArgs) ([]model.Obj, error) { |
| 38 | + basePath := "/" |
| 39 | + if dir != nil { |
| 40 | + if p := dir.GetPath(); p != "" { |
| 41 | + basePath = p |
| 42 | + } |
| 43 | + } |
| 44 | + return d.list(ctx, basePath) |
| 45 | +} |
| 46 | + |
| 47 | +func (d *Wps) Link(ctx context.Context, file model.Obj, _ model.LinkArgs) (*model.Link, error) { |
| 48 | + if file == nil { |
| 49 | + return nil, errs.NotSupport |
| 50 | + } |
| 51 | + return d.link(ctx, file.GetPath()) |
| 52 | +} |
| 53 | + |
| 54 | +func (d *Wps) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error { |
| 55 | + return d.makeDir(ctx, parentDir, dirName) |
| 56 | +} |
| 57 | + |
| 58 | +func (d *Wps) Move(ctx context.Context, srcObj, dstDir model.Obj) error { |
| 59 | + return d.move(ctx, srcObj, dstDir) |
| 60 | +} |
| 61 | + |
| 62 | +func (d *Wps) Rename(ctx context.Context, srcObj model.Obj, newName string) error { |
| 63 | + return d.rename(ctx, srcObj, newName) |
| 64 | +} |
| 65 | + |
| 66 | +func (d *Wps) Copy(ctx context.Context, srcObj, dstDir model.Obj) error { |
| 67 | + return d.copy(ctx, srcObj, dstDir) |
| 68 | +} |
| 69 | + |
| 70 | +func (d *Wps) Remove(ctx context.Context, obj model.Obj) error { |
| 71 | + return d.remove(ctx, obj) |
| 72 | +} |
| 73 | + |
| 74 | +func (d *Wps) Put(ctx context.Context, dstDir model.Obj, file model.FileStreamer, up driver.UpdateProgress) error { |
| 75 | + return d.put(ctx, dstDir, file, up) |
| 76 | +} |
| 77 | + |
| 78 | +var _ driver.Driver = (*Wps)(nil) |
0 commit comments