-
Notifications
You must be signed in to change notification settings - Fork 19
refactor(downloader): 重构Downloader #157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(downloader): 重构Downloader #157
Conversation
There was a problem hiding this 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 downloader functionality from a monolithic design into a modular architecture with cleaner separation of concerns. The refactor introduces mirror selection strategies, improved retry/resilience mechanisms using Polly, and comprehensive logging throughout the download lifecycle.
Key changes:
- Replaced old
Downloader,DownloadItem, andDownloadSegmentclasses with newDownloadManager,DownloadTask, andDownloadSegmentimplementations - Introduced
IMirrorSelectorinterface withFastMirrorSelectorimplementation for intelligent mirror selection based on latency - Integrated Polly resilience pipeline for retry logic with exponential backoff and timeout handling
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 28 comments.
Show a summary per file
| File | Description |
|---|---|
| Net/Downloader/MirrorFailedException.cs | New exception type for mirror-specific failures |
| Net/Downloader/IMirrorSelector.cs | Interface defining mirror selection contract |
| Net/Downloader/FastMirrorSelector.cs | Latency-based mirror selection implementation |
| Net/Downloader/DownloadTask.cs | Manages download task state, mirrors, and segment splitting |
| Net/Downloader/DownloadSegmentStatus.cs | Simplified enum for segment status tracking |
| Net/Downloader/DownloadSegment.cs | Handles individual segment downloads with range request support |
| Net/Downloader/DownloadRangeNotSupportedException.cs | Exception for servers not supporting range requests |
| Net/Downloader/DownloadManager.cs | Orchestrates parallel segment downloads with resilience |
| Net/Downloader.cs | Removed old implementation |
| Net/DownloadSegment.cs | Removed old implementation |
| Net/DownloadItem.cs | Removed old implementation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
建议直接写个新的,别改史山了.... |
/cc @ruattd 其实你可以直接看文件更改,我这个就等于重写 |
我是指,你连架构也重写掉,把它改的符合 HTTP 规范一点( |
但是我懒欸( |
你都用 AI 了,以及我之前写那个完全没经过测试的,建议你测一下到底能不能用( |
嗯?哪个?我不是很想(以及咱俩在GitHub这样聊天不太好啊) |
tangge233
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
等待实战 :\
wtommy932
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need it in my PR ( #131)
LGTM
wait for other's approval
Tip
这个是AI写的,AI真好用(
下载器功能重构PR说明
1. 主要修改内容
1.1 DownloadManager.cs
1.2 DownloadTask.cs
&运算符替换为%,确保循环索引正确SupprotsRange→SupportsRange,IMirrorSeletor→IMirrorSelector1.3 DownloadSegment.cs
FileOptions.Asynchronous提升异步IO性能1.4 日志系统集成
LogWrapper日志系统,提供不同级别的日志输出2. 测试情况
重构后的下载器功能已通过基础测试验证,测试用例位于
PCL.Test\Net\Downloader\DownloadManagerTest.cs:后续建议
本次重构显著提升了下载器的稳定性、性能和可维护性,为用户提供了更加可靠的文件下载体验。