Skip to content

Conversation

jenfonro
Copy link

@jenfonro jenfonro commented Sep 14, 2025

Description / 描述

修改百度云盘驱动在错误时支持断点续传

Motivation and Context / 背景

目前的驱动已经支持断点续传,但是只有用户主动取消才生效,现在将该逻辑去除,在任务未过期的情况下,会进行断点续传
主要用点在于,因网络错误上传中断时,进行继续上传

How Has This Been Tested? / 测试

Checklist / 检查清单

  • I have read the CONTRIBUTING document.
    我已阅读 CONTRIBUTING 文档。
  • I have formatted my code with go fmt or prettier.
    我已使用 go fmtprettier 格式化提交的代码。
  • I have added appropriate labels to this PR (or mentioned needed labels in the description if lacking permissions).
    我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
  • I have requested review from relevant code authors using the "Request review" feature when applicable.
    我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
  • I have updated the repository accordingly (If it’s needed).
    我已相应更新了相关仓库(若适用)。

ILoveScratch2

This comment was marked as outdated.

@jenfonro jenfonro changed the title 修改百度云盘驱动在错误时支持断点续传 fix(feat):BaiduNetdisk supports resuming uploads when an upload error occurs Sep 14, 2025
@jenfonro
Copy link
Author

jenfonro commented Sep 14, 2025

  1. 请修改 PR Title为正确格式,见 [Announcements] 关于规范 Pull Request Title / Merged Commit Messages #376
  2. 如需编译可使用Test Build,且该PR Feature与CI无关,不应修改
  3. 即使必须修改,也应该分多个PR,应做到一个功能一个PR

已经修改PR Tittle,workflow的release.yml也已经手动恢复为目前仓库main的版本,但是不太清楚应该怎么去除,还是我应该重新fork?

@jenfonro jenfonro changed the title fix(feat):BaiduNetdisk supports resuming uploads when an upload error occurs fix(upload):BaiduNetdisk supports resuming uploads when an upload error occurs Sep 14, 2025
@ILoveScratch2
Copy link
Member

  1. 请修改 PR Title为正确格式,见 [Announcements] 关于规范 Pull Request Title / Merged Commit Messages #376
  2. 如需编译可使用Test Build,且该PR Feature与CI无关,不应修改
  3. 即使必须修改,也应该分多个PR,应做到一个功能一个PR

已经修改PR Tittle,workflow的release.yml也已经手动恢复为目前仓库main的版本,但是不太清楚应该怎么去除,还是我应该重新fork?

可以手动直接还原更改前,也可用revert

Signed-off-by: jenfonro <[email protected]>
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the BaiduNetdisk driver to support resuming uploads when an upload error occurs, extending the existing resumable upload functionality beyond just user cancellations.

  • Removes the restriction that only allowed resumable uploads on user cancellation
  • Adds detection and handling for expired uploadid scenarios with automatic retry
  • Improves error messages and progress tracking during uploads

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
drivers/baidu_netdisk/driver.go Main implementation adding uploadid expiration detection, retry logic, and enhanced error handling for resumable uploads
.github/workflows/release.yml Removes trailing whitespace from workflow file

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@jenfonro
Copy link
Author

已更新,并完成测试

Comment on lines +356 to +375
params := map[string]string{"method": "precreate"}
form := map[string]string{
"path": path,
"size": strconv.FormatInt(streamSize, 10),
"isdir": "0",
"autoinit": "1",
"rtype": "3",
"block_list": blockListStr,
}
joinTime(form, ctime, mtime)
var newPre PrecreateResp
_, err2 := d.postForm("/xpan/file", params, form, &newPre)
if err2 != nil {
return nil, err2
}
if newPre.ReturnType == 2 {
newPre.File.Ctime = ctime
newPre.File.Mtime = mtime
return fileToObj(newPre.File), nil
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我觉得precreate的过程最好单独放在一个函数里,只是建议,你可以考虑一下

@KirCute KirCute changed the title fix(upload):BaiduNetdisk supports resuming uploads when an upload error occurs fix(baidu):BaiduNetdisk supports resuming uploads when an upload error occurs Sep 15, 2025
@KirCute KirCute changed the title fix(baidu):BaiduNetdisk supports resuming uploads when an upload error occurs fix(baidu_netdisk): support resuming uploads when an error occurs Sep 15, 2025
@KirCute
Copy link
Contributor

KirCute commented Sep 15, 2025

我不太清楚baidu_netdisk上传的具体流程,要是有更熟悉的人可以再看一下

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.

3 participants