Skip to content

feat(driver): add PDS storage driver#2663

Open
zymooll wants to merge 12 commits into
OpenListTeam:mainfrom
zymooll:main
Open

feat(driver): add PDS storage driver#2663
zymooll wants to merge 12 commits into
OpenListTeam:mainfrom
zymooll:main

Conversation

@zymooll

@zymooll zymooll commented Jun 26, 2026

Copy link
Copy Markdown

Summary / 摘要

修改概览

本次修改为 OpenList 新增原生 PDS 驱动,并在驱动注册表中启用 PDS 存储类型。驱动使用 PDS 官方接口完成文件列表、下载链接、上传、目录创建、重命名、移动、复制、回收站删除、容量信息读取和 OAuth Token 刷新。

主要变更

  • 新增 drivers/pds 驱动目录,按 OpenList 现有驱动结构拆分为元信息、API 客户端、数据类型和驱动实现。
  • drivers/all.go 中注册 PDS 驱动,确保程序启动时可在存储类型列表中发现 PDS
  • 支持通过 domain_iddrive_idaccess_tokenrefresh_token 等配置连接 PDS 空间。
  • 支持 Token 自动刷新,并在刷新成功后通过 op.MustSaveDriverStorage 写回存储配置。
  • 上传使用 /v2/file/create、预签名 PUT/v2/file/complete 的单分片流程。
  • 删除使用已验证的 /v2/recyclebin/trash,行为是移入 PDS 回收站,不做永久删除。
  • 下载链接通过 /v2/file/get 获取,并设置两小时链接缓存过期时间。
  • 新增 drivers/pds/README.md,说明驱动能力、配置项和实现注意事项。

文件说明

  • drivers/pds/meta.go:定义驱动配置项和注册逻辑。
  • drivers/pds/api.go:封装 PDS API 请求、Token 刷新和预签名上传请求。
  • drivers/pds/types.go:定义 PDS 响应结构,并转换为 OpenList model.Obj
  • drivers/pds/driver.go:实现 OpenList 驱动接口,包括读写、移动、复制、删除和容量详情。
  • drivers/pds/README.md:驱动使用说明。
  • drivers/all.go:增加 PDS 驱动 blank import。

行为与兼容性

  • 本次新增的是独立驱动,不修改既有驱动行为。

  • 删除动作进入 PDS 回收站,与永久删除不同。

  • expires_at 可填 0;只要配置了 refresh_token,驱动会在首次请求时刷新 Token。

  • 当前上传为单分片上传,适合作为最小可用实现;大文件分片并发上传可后续增强。

  • 新增了公开接口 /api/fs/complete_direct_upload

  • This PR has breaking changes.
    / 此 PR 包含破坏性变更。

  • This PR changes public API, config, storage format, or migration behavior.
    / 此 PR 修改了公开 API、配置、存储格式或迁移行为。

  • This PR requires corresponding changes in related repositories.
    / 此 PR 需要关联仓库同步修改。

Related repository PRs / 关联仓库 PR:

Testing / 测试

  • go test ./...
  • Manual test / 手动测试:
  • gofmt -w drivers/pds drivers/all.go
  • go test ./drivers/pds
  • 本地 demo 编译:go build -o build/openlist-demo.exe -tags=jsoniter .
  • 本地 demo 手动验证:
    • 登录 OpenList。
    • 创建 /pds 存储。
    • 列出 PDS 根目录。
    • 通过 OpenList API 上传测试文件到 /pds
    • 通过 OpenList API 删除测试文件,确认进入 PDS 回收站。

Checklist / 检查清单

  • I have read CONTRIBUTING.
    / 我已阅读 CONTRIBUTING
  • I confirm this contribution follows the repository license, contribution policy, and code of conduct.
    / 我确认此贡献符合仓库许可证、贡献规范和行为准则。
  • I have formatted the changed code with gofmt, go fmt, or prettier where applicable.
    / 我已按适用情况使用 gofmtgo fmtprettier 格式化变更代码。
  • I have requested review from relevant maintainers or code owners where applicable.
    / 我已在适用情况下请求相关维护者或代码所有者审查。

AI Disclosure / AI 使用声明

  • This PR includes AI-assisted content.
    / 此 PR 包含 AI 辅助内容。

Tools used / 使用工具:

  • ChatGPT
  • Codex
  • GitHub Copilot
  • Claude
  • Gemini
  • Other (please specify) / 其他(请注明):

Usage scope / 使用范围:

  • Code generation / 代码生成

  • Refactoring / 重构

  • Documentation / 文档

  • Tests / 测试

  • Translation / 翻译

  • Review assistance / 审查辅助

  • I have reviewed and validated all AI-assisted content included in this PR.
    / 我已审核并验证此 PR 中的所有 AI 辅助内容。

  • I have ensured that all AI-assisted commits include Co-Authored-By attribution.
    / 我已确保所有 AI 辅助提交都包含 Co-Authored-By 归属信息。

  • I can reproduce all AI-assisted content included in this PR without any AI tools.
    / 我可以在没有任何 AI 工具的情况下重现此 PR 中包含的所有 AI 辅助内容。

其他说明

PDS 服务文档:https://help.aliyun.com/zh/pds/drive-and-photo-service-ent/what-is-cde

zymooll added 2 commits June 27, 2026 06:27
- 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
@zymooll

zymooll commented Jun 27, 2026

Copy link
Copy Markdown
Author

新增配置文件 OAuth2 登录流程
关联 PR:OpenListTeam/OpenList-APIPages#90

@zymooll zymooll marked this pull request as ready for review June 27, 2026 13:35
Copilot AI review requested due to automatic review settings June 27, 2026 13:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@zymooll

zymooll commented Jun 27, 2026

Copy link
Copy Markdown
Author

文档也已经完成编辑。
关联PR:OpenListTeam/OpenList-Docs#340

@zymooll zymooll marked this pull request as draft June 27, 2026 16:50
@zymooll

zymooll commented Jun 27, 2026

Copy link
Copy Markdown
Author

新增一个 TODO LIST:需要修正逻辑,不走服务器中转上传。
Done

@zymooll zymooll marked this pull request as ready for review June 27, 2026 19:42
@zymooll

zymooll commented Jun 27, 2026

Copy link
Copy Markdown
Author

测试 Demo:https://openlist.206601.xyz/

@xrgzs

xrgzs commented Jun 28, 2026

Copy link
Copy Markdown
Member

和我这个重复了,#1936 。但目前我没有账号测试,无法继续开发。

@zymooll

zymooll commented Jun 28, 2026

Copy link
Copy Markdown
Author

和我这个重复了,#1936 。但目前我没有账号测试,无法继续开发。

好像还真是,因为我在现有 release 没看到有人做我以为就没人搞了。
我这个版本直接在 apipages 完成了 refrash_token 的获取了,然后另外做了一个直接上传的功能,就应该还算比较完善的了。

@zymooll

zymooll commented Jun 28, 2026

Copy link
Copy Markdown
Author

修复了一个小 BUG,概率性存在开始上传目标是 /PDS/1/111/0001.jpg,但后端返回的 complete.body.path 变成了 /PDS,完成上传时用错父目录,导致 token 里的 parent_file_id 和请求解析出的目录不一致,于是报 direct upload token does not match request。

@PIKACHUIM PIKACHUIM left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢您的贡献,还请提供一下‎internal内的改动的必要性

Comment thread internal/op/fs.go
Comment thread server/handles/direct_upload.go Outdated
@zymooll zymooll requested a review from PIKACHUIM June 30, 2026 22:30
@PIKACHUIM PIKACHUIM requested review from KirCute and xrgzs July 1, 2026 03:23
Comment thread drivers/pds/api.go
)

const (
defaultClientID = "lMNVp25Sd1MfqZDQ"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不应该内置吧

Comment thread drivers/pds/README.md Outdated
Comment thread drivers/pds/driver.go Outdated
Comment thread drivers/pds/upload.go
KawakazeNotFound and others added 3 commits July 1, 2026 21:35
- 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.
@zymooll zymooll requested review from jyxjjj and xrgzs July 1, 2026 14:22
@zymooll zymooll marked this pull request as draft July 1, 2026 15:31
@zymooll

zymooll commented Jul 1, 2026

Copy link
Copy Markdown
Author

TODO LIST:

  • 增加缩略图接口接入(WIP)

@zymooll zymooll marked this pull request as ready for review July 1, 2026 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants