Skip to content

fix(upload): show multipart storage errors and verify vanished sessions - #725

Open
thetapilla wants to merge 2 commits into
OpenListTeam:mainfrom
thetapilla:fix/multipart-error-display
Open

thetapilla wants to merge 2 commits into
OpenListTeam:mainfrom
thetapilla:fix/multipart-error-display

Conversation

@thetapilla

@thetapilla thetapilla commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary / 摘要

修复分块上传失败时上传列表只显示 multipart upload window closed,以及会话"消失"时误报上传成功的问题。

用户可感知的变化:

实现要点:

  • 分片响应中会话状态为 failed* 时显示 data.error,否则沿用 message
  • 轮询到 404 时用现有的 fsGet 查询目标文件;查询本身遇到网络抖动则继续轮询。已完成的会话会这样被回收,被取代或中止的会话也会,所以 404 本身不能证明上传成功

兼容性说明:上述检查只在 /complete 的响应丢失时才执行。在列表更新滞后于上传的存储上,它可能把实际成功的上传报为失败;相比把没传上去的文件报为成功,这样更稳妥。

  • 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:

Related Issues / 关联 Issue

Relates to OpenListTeam/OpenList#3309

Testing / 测试

测试平台:macOS arm64,Node 26 / pnpm 10。

  • go test ./...
    不适用前端仓
  • Manual test / 手动测试:

自动化检查:

  • pnpm test(40/40)、pnpm build 通过
  • pnpm lint(tsc):本 PR 未引入新的类型错误(仓库现存 13 个与本 PR 无关的既有错误,main 上同样存在)
  • 提交经 husky pre-commit 的 prettier 自动格式化
  • 在 Node 中对打包后的真实 multipart.ts 配合模拟服务端跑场景测试(不含在本 PR 中):分片失败时显示存储错误;会话消失时,目标文件存在且大小一致判成功、大小不一致判失败,且只查询一次;原有场景在新旧代码上都通过

浏览器实测:

  • 本地只读目录、MinIO 中途宕机、无法覆盖文件的 Samba 三种存储错误,上传列表都显示存储返回的真实原因
  • 吞掉 /complete 的响应:文件已在时判成功;完成后立即删除文件时报 upload session ended before completion
  • 分片连接被重置、CDN 返回 502:自动重试后完成

说明:main 的 pnpm-lock.yaml 缺 katex@0.18.2 条目,pnpm install --frozen-lockfile 会失败(#639 之后 main 的 Rolling Build 也因此失败),本 PR 的 CI 可能在安装依赖一步失败。本 PR 不涉及依赖,本地以 --no-frozen-lockfile 安装后测试,lockfile 未提交。

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.
    / 我已按适用情况使用 gofmt、go fmt 或 prettier 格式化变更代码。
  • 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 辅助内容。

thetapilla and others added 2 commits October 30, 2026 15:11
- When a chunk is rejected because the upload attempt failed, show the
  storage's error carried in the session snapshot instead of the generic
  envelope message. Servers that predate reporting the cause only said
  "multipart upload window closed" there.

Co-Authored-By: Claude <noreply@anthropic.com>
…cess

- When the complete response is lost and the session is then gone, the
  uploader took the 404 as success. Completed sessions are reaped that way,
  but so are superseded and aborted ones. Check that the destination exists
  with the uploaded size before reporting success, and fail otherwise.

Co-Authored-By: Claude <noreply@anthropic.com>
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.

1 participant