[release/3.10] 修复 MultipleSourceVersionList 不会使用备用下载源的问题#5588
[release/3.10] 修复 MultipleSourceVersionList 不会使用备用下载源的问题#5588Glavo merged 1 commit intoHMCL-dev:release/3.10from
Conversation
There was a problem hiding this comment.
Pull request overview
该 PR 旨在修复 MultipleSourceVersionList 在主下载源刷新失败时无法正确切换到备用下载源的问题,以提高版本列表拉取的可靠性(release/3.10 backport)。
Changes:
- 重写
MultipleSourceVersionList.refreshAsync(gameVersion, sourceIndex)的任务编排逻辑,使失败时可以继续尝试后续 source。 - 引入自定义
Task,通过 dependents/dependencies 组织“先尝试当前源,失败则递归尝试下一个源”的执行链。
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
HMCLCore/src/main/java/org/jackhuang/hmcl/download/MultipleSourceVersionList.java
Show resolved
Hide resolved
| public Collection<Task<?>> getDependents() { | ||
| return List.of(refreshTask); | ||
| } | ||
|
|
||
| @Override | ||
| public Collection<? extends Task<?>> getDependencies() { | ||
| return nextTask != null ? List.of(nextTask) : List.of(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isRelyingOnDependents() { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
This task continues execution when the dependent refreshTask fails (isRelyingOnDependents() returns false), but AsyncTaskExecutor still records the dependent failure into this task's exception field. If a later source succeeds, this task can finish successfully while getException() remains non-null (from the first failed source), which can break APIs that assume exception == null on success (e.g., Task.whenComplete asserts this invariant). Consider restructuring so failed source attempts do not count as failing dependents of the returned task (e.g., wrap source refreshes in a subtask that never fails and reports success via its result, or move fallback logic into a single task that only throws on final failure).
#5585