fix(driver): fix 189 & 189pc fastcopy form local storage#2471
Merged
Conversation
Member
Author
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Cloud189 (189) and Cloud189PC (189pc) drivers to improve “秒传/fastcopy” behavior when copying from sources that don’t provide MD5 (notably local storage), by ensuring the upload initialization request can include the required hashes.
Changes:
- 189pc: In
Put(stream mode), decide betweenRapidUpload(when MD5 already exists) vsFastUpload(when MD5 missing, to compute hashes and attempt 秒传). - 189: In
newUpload, precomputefileMd5andsliceMd5and include them in/person/initMultiUpload, and short-circuit to commit iffileDataExists == 1.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
drivers/189pc/driver.go |
Adds stream-mode “秒传” branching to prefer RapidUpload when MD5 exists, otherwise FastUpload to compute hashes. |
drivers/189/util.go |
Precomputes and passes fileMd5/sliceMd5 to initMultiUpload and commits immediately on server-side existence detection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
|
文字是不是改改,一会fast一会rapid |
jyxjjj
approved these changes
May 12, 2026
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.

Description / 描述
修复 189 和 189pc 驱动在从本地存储(或其他不提供 MD5 Hash 的存储)复制文件到天翼云时,即使云端已存在相同文件也无法触发秒传的问题。
修改后,两个驱动在上传前会先计算文件完整 MD5 和分片 MD5(sliceMd5),在
initMultiUpload请求中携带这些信息,使天翼云服务端能够正确判断文件是否已存在,从而实现秒传。Motivation and Context / 背景
问题现象
用户从本地存储复制文件到天翼云(189/189pc)时,即使云端已存在完全相同的文件,也无法触发秒传,必须重新上传整个文件。
根本原因
问题由 三层原因 叠加导致:
本地驱动不提供 MD5 Hash:本地驱动(Local)创建的
model.Object不包含HashInfo,GetHash()返回空值。复制流程原样传递空 Hash:
copy_move.go中创建SeekableStream时直接使用源文件对象(srcObj),Hash 信息为空被原样传递到目标驱动。上传方法未携带 MD5 参数:
stream,StreamUpload的initMultiUpload请求中不传递fileMd5和sliceMd5参数(只传lazyCheck: "1"),服务端无法判断文件是否已存在。initMultiUpload中只传lazyCheck: "1",不传fileMd5,无法触发秒传。对比分析
parentFolderIdfileNamefileSizesliceSizefileMd5sliceMd5lazyCheck"1"Relates to: 从本地复制到天翼云无法秒传
修改逻辑
1. 189pc 驱动 (
drivers/189pc/driver.go)在
Put方法的case "stream"分支中,增加秒传预判断逻辑:关键点:
FastUpload内部会:\n拼接后再取 MD5 得到sliceMd5initMultiUpload中传递fileMd5和sliceMd5FileDataExists == 1判断是否秒传成功如果秒传失败(
FileDataExists != 1),FastUpload会继续正常分片上传。如果
RapidUpload失败,会 fallthrough 到StreamUpload正常上传。2. 189 驱动 (
drivers/189/util.go)重构
newUpload方法,在initMultiUpload之前增加 MD5 预计算逻辑:Step 1 - 计算文件 MD5 和分片 MD5:
Step 2 - 带 MD5 调用 initMultiUpload:
Step 3 - 秒传判断:
3. 189_tv 驱动 - 无需修改
189_tv 的
OldUpload方法已内置 MD5 缺失时自动计算并尝试秒传的逻辑(CacheFullAndHash),流程本身是正确的。How Has This Been Tested? / 测试
测试场景
本地 → 189pc(stream模式)秒传测试
本地 → 189 秒传测试
本地 → 189pc 正常上传测试(非秒传)
天翼云 → 天翼云 复制测试(已有MD5)
大文件秒传测试
零字节文件测试
验证方法
initMultiUpload请求中包含fileMd5和sliceMd5参数fileDataExists字段为1(秒传成功时)预期效果
Checklist / 检查清单
我已阅读 CONTRIBUTING 文档。
go fmtor prettier.我已使用
go fmt或 prettier 格式化提交的代码。我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。