Skip to content

feat(driver): add PDS storage driver#2663

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

feat(driver): add PDS storage driver#2663
zymooll wants to merge 3 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/

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.

2 participants