Skip to content

Conversation

@Dainsleif233
Copy link
Contributor

@Dainsleif233 Dainsleif233 commented Dec 16, 2025

Checklist

  • Changes have been tested locally and work as expected.
  • All tests in workflows pass successfully.
  • Documentation has been updated if necessary.
  • Code formatting and commit messages align with the project's conventions.
  • Comments have been added for any complex logic or functionality if possible.

This PR is a ..

  • 🛠 Refactoring

Related Issues

Description

  • 下载改成传入URL数组,响应错或哈希验证错误时依次尝试。
  • 安装Modrinth格式整合包时会将文件downloads全部传入。

@UNIkeEN
Copy link
Owner

UNIkeEN commented Dec 17, 2025

related issue可以加一些关键词,以在合并 PR 后自动关闭 issue~
(比如 close #1025 ,这样写就自动 link 上了,github 对关键词列表有文档的但我找不到了喵)

本条 PR 将在本周末(如届时已经 ready for review)由后端同学 review

@Dainsleif233
Copy link
Contributor Author

就先这样吧,本来想加多线程

@Dainsleif233 Dainsleif233 marked this pull request as ready for review December 17, 2025 13:27
@ToolmanP
Copy link
Collaborator

有哪个场景需要这样子的重构?

@Dainsleif233
Copy link
Contributor Author

有哪个场景需要这样子的重构?

安装modrinth整合包时

.map(|file| {
let download_url = file
.downloads
.first()
.ok_or(InstanceError::InvalidSourcePath)?;

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 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 DownloadParam and DownloadTaskPayload to 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

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.

[Feature] 下载任务新增 fallback src

3 participants