-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat(driver): add personal / business wps drive support #1802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8880572
feat(driver): add wps drive support
x-spy 650df1d
feat(driver): add wps drive support
x-spy 9ed88c0
fix(wps): update personal mode string to English
xrgzs 67da7f8
fix(wps): remove trailing slash from drive origin URL
xrgzs a222d3c
fix(wps): correct order of options in mode selection
xrgzs 0c60434
fix(wps): enable local sort and upload overwrite
xrgzs b5b0a7b
fix(wps): resolve put bugs, fix file op problems and optimize list logic
x-spy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| package wps | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
|
|
||
| "github.com/OpenListTeam/OpenList/v4/internal/driver" | ||
| "github.com/OpenListTeam/OpenList/v4/internal/errs" | ||
| "github.com/OpenListTeam/OpenList/v4/internal/model" | ||
| ) | ||
|
|
||
| type Wps struct { | ||
| model.Storage | ||
| Addition | ||
| companyID string | ||
| } | ||
|
|
||
| func (d *Wps) Config() driver.Config { | ||
| return config | ||
| } | ||
|
|
||
| func (d *Wps) GetAddition() driver.Additional { | ||
| return &d.Addition | ||
| } | ||
|
|
||
| func (d *Wps) Init(ctx context.Context) error { | ||
| if d.Cookie == "" { | ||
| return fmt.Errorf("cookie is empty") | ||
| } | ||
| return d.ensureCompanyID(ctx) | ||
| } | ||
|
|
||
| func (d *Wps) Drop(ctx context.Context) error { | ||
| return nil | ||
| } | ||
|
|
||
| func (d *Wps) List(ctx context.Context, dir model.Obj, _ model.ListArgs) ([]model.Obj, error) { | ||
| basePath := "/" | ||
| if dir != nil { | ||
| if p := dir.GetPath(); p != "" { | ||
| basePath = p | ||
| } | ||
| } | ||
| return d.list(ctx, basePath) | ||
| } | ||
|
|
||
| func (d *Wps) Link(ctx context.Context, file model.Obj, _ model.LinkArgs) (*model.Link, error) { | ||
| if file == nil { | ||
| return nil, errs.NotSupport | ||
| } | ||
| return d.link(ctx, file.GetPath()) | ||
| } | ||
|
|
||
| func (d *Wps) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error { | ||
| return d.makeDir(ctx, parentDir, dirName) | ||
| } | ||
|
|
||
| func (d *Wps) Move(ctx context.Context, srcObj, dstDir model.Obj) error { | ||
| return d.move(ctx, srcObj, dstDir) | ||
| } | ||
|
|
||
| func (d *Wps) Rename(ctx context.Context, srcObj model.Obj, newName string) error { | ||
| return d.rename(ctx, srcObj, newName) | ||
| } | ||
|
|
||
| func (d *Wps) Copy(ctx context.Context, srcObj, dstDir model.Obj) error { | ||
| return d.copy(ctx, srcObj, dstDir) | ||
| } | ||
|
|
||
| func (d *Wps) Remove(ctx context.Context, obj model.Obj) error { | ||
| return d.remove(ctx, obj) | ||
| } | ||
|
|
||
| func (d *Wps) Put(ctx context.Context, dstDir model.Obj, file model.FileStreamer, up driver.UpdateProgress) error { | ||
| return d.put(ctx, dstDir, file, up) | ||
| } | ||
|
|
||
| var _ driver.Driver = (*Wps)(nil) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package wps | ||
|
|
||
| import ( | ||
| "github.com/OpenListTeam/OpenList/v4/internal/driver" | ||
| "github.com/OpenListTeam/OpenList/v4/internal/op" | ||
| ) | ||
|
|
||
| type Addition struct { | ||
| driver.RootPath | ||
| Cookie string `json:"cookie" required:"true" type:"text"` | ||
| Mode string `json:"mode" type:"select" options:"Personal,Business" default:"Business"` | ||
| } | ||
|
|
||
| var config = driver.Config{ | ||
| Name: "WPS", | ||
| LocalSort: true, | ||
| DefaultRoot: "/", | ||
| Alert: "", | ||
| NoOverwriteUpload: true, | ||
| } | ||
|
|
||
| func init() { | ||
| op.RegisterDriver(func() driver.Driver { | ||
| return &Wps{} | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| package wps | ||
|
|
||
| import ( | ||
| "time" | ||
|
|
||
| "github.com/OpenListTeam/OpenList/v4/pkg/utils" | ||
| ) | ||
|
|
||
| type workspaceResp struct { | ||
| Companies []struct { | ||
| ID int64 `json:"id"` | ||
| } `json:"companies"` | ||
| } | ||
|
|
||
| type Group struct { | ||
| CompanyID int64 `json:"company_id"` | ||
| GroupID int64 `json:"group_id"` | ||
| Name string `json:"name"` | ||
| Type string `json:"type"` | ||
| } | ||
|
|
||
| type groupsResp struct { | ||
| Groups []Group `json:"groups"` | ||
| } | ||
|
|
||
| type filePerms struct { | ||
| Download int `json:"download"` | ||
| } | ||
|
|
||
| type FileInfo struct { | ||
| GroupID int64 `json:"groupid"` | ||
| ParentID int64 `json:"parentid"` | ||
| Name string `json:"fname"` | ||
| Size int64 `json:"fsize"` | ||
| Type string `json:"ftype"` | ||
| Ctime int64 `json:"ctime"` | ||
| Mtime int64 `json:"mtime"` | ||
| ID int64 `json:"id"` | ||
| Deleted bool `json:"deleted"` | ||
| FilePerms filePerms `json:"file_perms_acl"` | ||
| } | ||
|
|
||
| type filesResp struct { | ||
| Files []FileInfo `json:"files"` | ||
| } | ||
|
|
||
| type downloadResp struct { | ||
| URL string `json:"url"` | ||
| Result string `json:"result"` | ||
| } | ||
|
|
||
| type Obj struct { | ||
| id string | ||
| name string | ||
| size int64 | ||
| ctime time.Time | ||
| mtime time.Time | ||
| isDir bool | ||
| hash utils.HashInfo | ||
| path string | ||
| canDownload bool | ||
| } | ||
|
|
||
| func (o *Obj) GetSize() int64 { | ||
| return o.size | ||
| } | ||
|
|
||
| func (o *Obj) GetName() string { | ||
| return o.name | ||
| } | ||
|
|
||
| func (o *Obj) ModTime() time.Time { | ||
| return o.mtime | ||
| } | ||
|
|
||
| func (o *Obj) CreateTime() time.Time { | ||
| return o.ctime | ||
| } | ||
|
|
||
| func (o *Obj) IsDir() bool { | ||
| return o.isDir | ||
| } | ||
|
|
||
| func (o *Obj) GetHash() utils.HashInfo { | ||
| return o.hash | ||
| } | ||
|
|
||
| func (o *Obj) GetID() string { | ||
| return o.id | ||
| } | ||
|
|
||
| func (o *Obj) GetPath() string { | ||
| return o.path | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.