Skip to content

Conversation

@xrgzs
Copy link
Member

@xrgzs xrgzs commented Aug 29, 2025

Description / 描述

重构新个人云的分片上传逻辑,逐批获取上传链接并上传,避免分片上传地址过期导致上传失败。

对分片上传信息进行排序,避免因排序错误导致上传失败。

优化错误处理,返回分片上传错误信息。

Motivation and Context / 背景

Closes https://github.com/orgs/OpenListTeam/discussions/1167

How Has This Been Tested? / 测试

返回的分片排序不正确:

image

能够使用正确的顺序上传分片:

image

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).
    我已相应更新了相关仓库(若适用)。

Signed-off-by: MadDogOwner <xiaoran@xrgzs.top>
@xrgzs xrgzs requested a review from Copilot August 29, 2025 11:42

This comment was marked as outdated.

Signed-off-by: MadDogOwner <xiaoran@xrgzs.top>
@xrgzs
Copy link
Member Author

xrgzs commented Aug 29, 2025

不对不对,官网上传也是一次性获取所有地址。反倒是越改越错。如果是分批调用 /file/getUploadUrl 的话,请求 101~200 分片,返回从 190 开始。

成功复现 400 报错,内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<Error>
  <Code>InvalidPartOrder</Code>
  <Message>fail to get previous part hash context</Message>
  <BucketName>ykj-eos-dgx-0x</BucketName>
  <RequestId>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx-dongguanx-zone1</RequestId>
  <HostId>xxxxxxxx-dongguanx-zone1-dongguan6</HostId>
</Error>

@xrgzs
Copy link
Member Author

xrgzs commented Aug 29, 2025

请求 101~200 分片,返回从 190 开始。

仔细看了下,是数组排序不对,匹配到错误的分片上传,肯定不正常。

xrgzs added 2 commits August 29, 2025 23:43
Signed-off-by: MadDogOwner <xiaoran@xrgzs.top>
Signed-off-by: MadDogOwner <xiaoran@xrgzs.top>
@xrgzs xrgzs requested a review from Copilot August 29, 2025 16:03
Copy link
Contributor

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 refactors the multipart upload logic for the 139 cloud driver to improve reliability and error handling. The key changes focus on batch processing upload URLs and proper sorting to prevent upload failures.

  • Extracts upload logic into a separate reusable function for better maintainability
  • Implements batch processing to avoid upload URL expiration issues
  • Adds proper sorting of part upload information and enhanced error handling

Reviewed Changes

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

File Description
drivers/139/util.go Adds new uploadPersonalParts function with proper sorting and error handling for multipart uploads
drivers/139/driver.go Refactors main upload logic to use batch processing and the new upload function

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

…ds errors

Signed-off-by: MadDogOwner <xiaoran@xrgzs.top>
@xrgzs xrgzs marked this pull request as ready for review August 29, 2025 16:07
Copy link
Member

@KirCute KirCute left a comment

Choose a reason for hiding this comment

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

LGTM

@xrgzs xrgzs merged commit 87cf95f into OpenListTeam:main Aug 31, 2025
12 checks passed
@xrgzs xrgzs deleted the fix/139-upload branch August 31, 2025 07:47
ForSourceCodeAnalysis pushed a commit to ForSourceCodeAnalysis/OpenList that referenced this pull request Oct 4, 2025
* fix(139): refactor part upload logic

Signed-off-by: MadDogOwner <xiaoran@xrgzs.top>

* fix(139): handle upload errors

Signed-off-by: MadDogOwner <xiaoran@xrgzs.top>

* fix(139): sort upload parts by PartNumber before uploading

Signed-off-by: MadDogOwner <xiaoran@xrgzs.top>

* fix(139): improve error handling

Signed-off-by: MadDogOwner <xiaoran@xrgzs.top>

* fix(139): add validation for upload part index to prevent out of bounds errors

Signed-off-by: MadDogOwner <xiaoran@xrgzs.top>

---------

Signed-off-by: MadDogOwner <xiaoran@xrgzs.top>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants