Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical logic bug in the Task.updateProgress(long count, long total) method where the comparison condition was inverted, causing progress to be incorrectly calculated. The bug would have resulted in progress being set to 100% when tasks were just starting (when total >= count), and attempting to calculate progress as count/total when count exceeded total.
Changes:
- Fixed inverted condition in
updateProgressmethod: changedif (total >= count)toif (count >= total)to correctly set progress to 1.0 when the task is complete
Comments suppressed due to low confidence (1)
HMCLCore/src/main/java/org/jackhuang/hmcl/task/Task.java:355
- The updateProgress method lacks test coverage. Consider adding unit tests to verify the progress calculation logic, especially for edge cases:
- When count equals total (should return 1.0)
- When count is less than total (should return count/total)
- When count exceeds total (should return 1.0, not > 1.0)
This would have caught the original bug where the condition was inverted.
protected void updateProgress(long count, long total) {
if (count < 0 || total < 0)
throw new IllegalArgumentException("Invalid count or total: count=" + count + ", total=" + total);
double progress;
if (count >= total)
progress = 1.0;
else
progress = (double) count / total;
updateProgress(progress);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Jeinse
added a commit
to Jeinse/HMCL
that referenced
this pull request
Feb 15, 2026
Fix HMCL-dev#5525: 修复 Task 进度异常的问题 (HMCL-dev#5543)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.