Sync/upstream merge - #3030
Conversation
- add a native PDS driver with list, link, upload, mkdir, rename, move, copy, recycle-bin delete, and storage details support - persist refreshed OAuth tokens and allow either access_token or refresh_token for authentication - register the driver and cover initialization/query escaping behavior with focused tests
feat(driver): add PDS storage driver
- Move PDS helper functions out of driver.go into util.go. - Remove the PDS driver test file from the tracked tree while keeping local tests available.
|
如果跨多个组件,请使用主要组件作为前缀,并在标题中枚举、描述中说明。 如果是破坏性变更,请在类型后添加 |
There was a problem hiding this comment.
🟡 Changes recommended
PDS direct-upload completion currently doesn’t bind the request file_name to the signed token, weakening the handler’s permission/mount-path checks.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds a “complete direct upload” API and plumbing to finalize client-side direct uploads, and introduces a new PDS storage driver that supports direct upload sessions (issue token → client uploads bytes → server commits session).
Changes:
- Added
/api/fs/complete_direct_uploadendpoint to commit a previously initiated direct-upload session. - Added
DirectUploadCompleterdriver interface plusfs/opplumbing to execute completion and trigger object-update hooks. - Added new
drivers/pdsimplementation, including direct upload token signing and completion logic, and registered it indrivers/all.go.
File summaries
| File | Description |
|---|---|
| server/router.go | Registers the new direct-upload completion route under the fs API group. |
| server/handles/direct_upload.go | Implements FsCompleteDirectUpload handler with path resolution and permission checks. |
| internal/op/fs.go | Adds op.CompleteDirectUpload for driver-level completion + hook trigger. |
| internal/fs/put.go | Adds internal completeDirectUpload helper to resolve storage and call op layer. |
| internal/fs/fs.go | Exposes fs.CompleteDirectUpload wrapper with logging. |
| internal/driver/driver.go | Introduces DirectUploadCompleter interface for drivers that can commit direct uploads. |
| drivers/all.go | Registers the new PDS driver. |
| drivers/pds/api.go | Adds PDS API client, token refresh handling, and request helpers. |
| drivers/pds/driver.go | Implements core PDS driver operations (Init/List/Get/Link/CRUD-like ops). |
| drivers/pds/meta.go | Defines PDS driver config/addition fields and registers the driver. |
| drivers/pds/types.go | Defines PDS response types and conversion to model.Obj. |
| drivers/pds/upload.go | Implements PDS direct upload initiation + completion and token signing/verification. |
| drivers/pds/util.go | Adds helpers for PDS path/object lookups and query escaping. |
Review details
- Files reviewed: 13/13 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if token.DomainID != d.DomainID || token.DriveID != d.DriveID || | ||
| token.ParentFileID != d.fileID(dstDir) { | ||
| return nil, fmt.Errorf("direct upload token does not match request") | ||
| } | ||
| if token.FileID == "" || token.UploadID == "" { |
| func (d *PDS) verifyDirectUploadToken(raw string) (*directUploadToken, error) { | ||
| payloadText, signature, ok := strings.Cut(raw, ".") | ||
| if !ok || payloadText == "" || signature == "" { | ||
| return nil, fmt.Errorf("invalid direct upload token") | ||
| } |
No description provided.