-
Notifications
You must be signed in to change notification settings - Fork 49
refactor(download): 重构下载任务逻辑,添加对多源下载的支持 #1211
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
base: main
Are you sure you want to change the base?
Conversation
|
related issue可以加一些关键词,以在合并 PR 后自动关闭 issue~ 本条 PR 将在本周末(如届时已经 ready for review)由后端同学 review |
|
就先这样吧,本来想加多线程 |
|
有哪个场景需要这样子的重构? |
安装modrinth整合包时 SJMCL/src-tauri/src/instance/helpers/modpack/modrinth.rs Lines 110 to 114 in d7a9d10
|
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 download task system to support multiple source URLs with automatic fallback. When a download fails due to network errors or SHA1 hash validation failures, the system will automatically retry using alternative mirror URLs. The key change is converting the src field from a single URL to an array of URLs throughout both the TypeScript frontend and Rust backend.
Key Changes
- Modified
DownloadParamandDownloadTaskPayloadto use URL arrays instead of single URLs in both frontend (src/models/task.ts) and backend (src-tauri/src/tasks/download.rs) - Implemented retry loop logic in the download task that attempts each source URL sequentially on failure, with automatic cleanup and state reset between attempts
- Updated Modrinth modpack installation to pass all available download mirrors from the manifest to leverage multi-source support
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/models/task.ts | Changed src field from string to string[] in download task type definitions |
| src/pages/settings/dev-test.tsx | Updated test page to wrap download URL in array |
| src/components/modals/download-specific-resource-modal.tsx | Wrapped single download URL in array for resource downloads |
| src-tauri/src/tasks/download.rs | Core refactoring: changed src to Vec<Url>, implemented multi-source retry loop with error handling and state cleanup |
| src-tauri/src/tasks/streams/mod.rs | Removed automatic completion marking from stream end (now handled explicitly after SHA1 validation) |
| src-tauri/src/instance/helpers/modpack/modrinth.rs | Updated to pass all available download URLs from Modrinth manifest for each file |
| src-tauri/src/instance/helpers/modpack/curseforge.rs | Wrapped CurseForge download URL in array |
| src-tauri/src/instance/helpers/loader/*.rs | Wrapped loader installer and library URLs in arrays across forge, neoforge, and fabric loaders |
| src-tauri/src/launch/helpers/file_validator.rs | Wrapped library and asset download URLs in arrays |
| src-tauri/src/resource/commands.rs | Wrapped resource download URLs in arrays |
| src-tauri/src/resource/helpers/modrinth/mod.rs | Wrapped Fabric API mod download URL in array |
| src-tauri/src/launcher_config/helpers/java.rs | Wrapped Java runtime download URLs in arrays |
| src-tauri/src/launcher_config/helpers/updater.rs | Wrapped launcher update download URL in array |
| src-tauri/src/instance/commands.rs | Wrapped client jar download URL in array |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Checklist
This PR is a ..
Related Issues
Description