Repository navigation
Conversation
- Return the error received from the multipart upload error channel. - Prevent successful nil results from reaching the upload result dereference. Co-authored-by: LunelleEverdawn <lunelle+suyunmeng@oplist.org>
- Map permission failures to 403 and unsupported uploads to 405. - Return 500 for other backend upload failures instead of 405. Co-authored-by: LunelleEverdawn <lunelle+suyunmeng@oplist.org>
- Cancel multipart workers on upload failures and timeout. - Close upload channels after workers exit and abort failed uploads. Co-authored-by: LunelleEverdawn <lunelle+suyunmeng@oplist.org>
There was a problem hiding this comment.
🟡 Changes recommended
Two unresolved moderate issues remain: WebDAV upload errors for unimplemented or unsupported drivers now return 500 instead of 405, and the 115 upload path can discard a real chunk error when token refresh also fails.
2 open issues
What changed in this PR
This PR fixes a 115 driver bug where a multipart upload failure could return a nil result and cause a nil-pointer panic. It also changes how WebDAV maps upload errors to HTTP status codes. The 115 fix addresses issue #3201.
Changes:
- Rewrites the 115 multipart upload flow to use a cancellable context, report the first real error, abort the OSS multipart session on failure, and wait for workers to finish.
- Maps WebDAV PUT errors to 403 for permission failures, 405 for unsupported uploads, and 500 for other backend failures.
| File | Description |
|---|---|
| server/webdav/webdav.go | Maps upload errors to 403, 405, or 500 instead of always returning 405. |
| drivers/115/util.go | Propagates real chunk errors, cancels workers on failure, and aborts the OSS multipart session. |
Review effort: Lite
| if tokenErr != nil { | ||
| uploadErr = tokenErr | ||
| cancel() | ||
| break LOOP |
| if errors.Is(err, errs.UploadNotSupported) { | ||
| return http.StatusMethodNotAllowed, err | ||
| } |
jyxjjj
left a comment
There was a problem hiding this comment.
[P2] 不支持上传的错误没有覆盖完整,部分原本返回 405 的情况会变成 500。
server/webdav/webdav.go:538
这里只匹配 UploadNotSupported,但 op.Put 在驱动没有实现 Put 时返回 NotImplement,一些驱动的 Put 也直接返回 NotSupport。它们现在都会落到 500,和这次保留“不支持上传返回 405”的目标不一致。
要把 NotImplement、NotSupport 一起映射到 405,并覆盖这些错误经过包装后的情况。
[P2] 刷新 token 失败时仍然可能丢掉已经上报的分片错误。
drivers/115/util.go:437
主循环进入 GetOSSToken 后,worker 可能先把分片错误写入 errCh 并取消上传。如果 GetOSSToken 随后也失败,这里会直接返回 tokenErr,没有读取已经排队的分片错误,原始上传失败原因就被覆盖了。
要和 timeout 分支一样,优先取 errCh 中已经上报的错误,没有时再使用 tokenErr。
Generated by ChatGPT-6.1-Sol Medium

Summary / 摘要
修复 115 分片上传丢失真实错误的问题,避免上传失败时返回
nil结果并触发后续空指针崩溃。Fix lost errors in 115 multipart uploads to prevent nil results and downstream nil-pointer panics.
改进 WebDAV 上传失败的 HTTP 状态码映射:权限错误返回 403,不支持上传返回 405,其他后端失败返回 500。
Improve WebDAV upload error mapping: permission failures return 403, unsupported uploads return 405, and other backend failures return 500.
完善 multipart worker、channel、context 和 OSS multipart session 的生命周期清理。
Clean up multipart worker, channel, context, and OSS multipart-session lifecycles.
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
Fixes #3201
Testing / 测试
go test ./...go test ./drivers/115 ./server/webdavgofmtandgit diff --checkChecklist / 检查清单
/ 我已阅读 CONTRIBUTING。
/ 我确认此贡献符合仓库许可证、贡献规范和行为准则。
gofmt,go fmt, orprettierwhere applicable./ 我已按适用情况使用
gofmt、go fmt或prettier格式化变更代码。/ 我已在适用情况下请求相关维护者或代码所有者审查。
AI Disclosure / AI 使用声明
/ 此 PR 包含 AI 辅助内容。
Tools used / 使用工具:
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-Byattribution./ 我已确保所有 AI 辅助提交都包含
Co-Authored-By归属信息。I can reproduce all AI-assisted content included in this PR without any AI tools.
/ 我可以在没有任何 AI 工具的情况下重现此 PR 中包含的 AI 辅助内容。