Skip to content

Conversation

@j2rong4cn
Copy link
Member

Description / 描述

url并发下载支持速率限制

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

@j2rong4cn j2rong4cn requested review from KirCute, Copilot and xrgzs and removed request for xrgzs November 3, 2025 09: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 rate limiting logic for range readers and consolidates duplicate code. The main focus is on cleaning up how RateLimitReader is applied and removing redundant wrapper types.

  • Simplified rate limiting logic by applying RateLimitReader directly in GetRangeReaderFromLink instead of wrapping with RateLimitRangeReaderFunc
  • Removed the need for FileRangeReader wrapper in driver-level Link implementations where the underlying reader doesn't actually support file operations
  • Improved context error checking by replacing the custom utils.IsCanceled check with direct Ctx.Err() calls

Reviewed Changes

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

Show a summary per file
File Description
internal/stream/util.go Restructured GetRangeReaderFromLink to apply rate limiting at HTTP client level for both URL and RangeReader paths; changed return type of GetRangeReaderFromMFile to *model.FileRangeReader
internal/stream/limit.go Simplified context cancellation checks by using Ctx.Err() directly; optimized RateLimitRangeReaderFunc to check for nil limiter before executing
internal/net/util.go Replaced custom LimitedReadCloser implementation with readers.NewLimitedReadCloser from rclone library
internal/model/file.go Added documentation comment explaining the purpose of FileRangeReader wrapper
internal/model/args.go Changed ContentLength field JSON tag from "-" to "content_length" to enable serialization
drivers/proton_drive/driver.go Removed unnecessary FileRangeReader wrapper as the underlying reader doesn't support file operations
drivers/ftp/driver.go Removed unnecessary FileRangeReader wrapper as the underlying reader doesn't support file operations
Comments suppressed due to low confidence (1)

internal/stream/util.go:113

  • Corrected spelling of 'perfromace' to 'performance'.
			log.Warnf("remote http server not supporting range request, expect low perfromace!")

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@j2rong4cn j2rong4cn merged commit 6de15b6 into OpenListTeam:main Nov 4, 2025
18 checks passed
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.

2 participants