Repository navigation
fix(upload): send a file identity so multipart uploads can resume - #726
Open
thetapilla wants to merge 1 commit into
Open
thetapilla wants to merge 1 commit into
thetapilla wants to merge 1 commit into
Conversation
- A receiving multipart session only resumes when the client proves it is re-uploading the same file. The uploader only had file hashes for that, and computes them only when rapid upload is requested, so by default a reload restarted the upload from scratch. - Send X-File-Identity on init: a SHA-256 over the first and last MiB of the file plus its size and modification time, computed with hash-wasm (crypto.subtle is unavailable over plain HTTP). It is sent on every multipart upload; servers that do not know the header ignore it. Co-Authored-By: Claude <noreply@anthropic.com>
16 of 25 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary / 摘要
让分块上传在不勾"尝试秒传"时也能断点续传。
用户可感知的变化:
实现要点:
X-File-Identity:对文件首尾各 1 MiB 加上文件大小和修改时间计算 SHA-256,用现有依赖hash-wasm计算(纯 HTTP 下没有crypto.subtle)。每个文件最多读取 2 MiB,大文件也不需要等待兼容性说明:不认识
X-File-Identity的服务端会忽略它,行为与现在相同。/ 此 PR 包含破坏性变更。
/ 此 PR 修改了公开 API、配置、存储格式或迁移行为。
/ 此 PR 需要关联仓库同步修改。
Related repository PRs / 关联仓库 PR:
Testing / 测试
测试平台:macOS arm64,Node 26 / pnpm 10。
go test ./...不适用前端仓
自动化检查:
pnpm test(40/40)、pnpm build通过pnpm lint(tsc):本 PR 未引入新的类型错误(仓库现存 13 个与本 PR 无关的既有错误,main 上同样存在)multipart.ts配合模拟服务端跑场景测试(不含在本 PR 中):不勾秒传也发送指纹;同一文件重新选择后指纹不变;文件被修改后指纹改变;原有场景在新旧代码上都通过浏览器实测:
说明:main 的
pnpm-lock.yaml缺katex@0.18.2条目,pnpm install --frozen-lockfile会失败(#639 之后 main 的 Rolling Build 也因此失败),本 PR 的 CI 可能在安装依赖一步失败。本 PR 不涉及依赖,本地以--no-frozen-lockfile安装后测试,lockfile 未提交。Checklist / 检查清单
/ 我已阅读 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 辅助内容。