优化 Linux 平台硬件检测#3946
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances hardware detection on Linux by adding fallback logic, introducing a toggle for fastfetch usage, and improving FastFetchUtils parsing and executable resolution.
- Linux detector now falls back to the superclass methods if Linux-specific probes return null/empty.
- A
hmcl.hardware.fastfetchsystem property controls whether fastfetch is used by default. - FastFetchUtils now filters out leading garbage from output and picks the right executable per OS.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| HMCLCore/src/main/java/org/jackhuang/hmcl/util/platform/linux/LinuxHardwareDetector.java | Add null/empty fallbacks for CPU/GPU detection |
| HMCLCore/src/main/java/org/jackhuang/hmcl/util/platform/hardware/HardwareDetector.java | Introduce USE_FAST_FETCH flag driven by system property |
| HMCLCore/src/main/java/org/jackhuang/hmcl/util/platform/hardware/FastFetchUtils.java | Select .exe on Windows, strip leading garbage, and update logs |
Comments suppressed due to low confidence (2)
HMCLCore/src/main/java/org/jackhuang/hmcl/util/platform/linux/LinuxHardwareDetector.java:56
- [nitpick] The variable name
fastfetchResultsis a bit ambiguous—consider renaming it tofallbackCardsto clearly indicate its purpose.
List<GraphicsCard> fastfetchResults = super.detectGraphicsCards();
HMCLCore/src/main/java/org/jackhuang/hmcl/util/platform/linux/LinuxHardwareDetector.java:53
- Returning
nullfor non-Linux platforms may force callers to null-check; consider returning an empty list instead to simplify API usage.
return null;
Comment on lines
43
to
45
| private static <T> T get(String type, TypeToken<T> resultType) { | ||
| Path fastfetch = SystemUtils.which("fastfetch"); | ||
| Path fastfetch = SystemUtils.which(OperatingSystem.CURRENT_OS == OperatingSystem.WINDOWS ? "fastfetch.exe" : "fastfetch"); | ||
| if (fastfetch == null) |
There was a problem hiding this comment.
Invoking which on every call can be costly; consider caching the resolved fastfetch path in a static field to avoid repeated lookups.
zkitefly
reviewed
May 29, 2025
| */ | ||
| @SuppressWarnings("ALL") | ||
| public class HardwareDetector { | ||
| private static final boolean USE_FAST_FETCH = "true".equalsIgnoreCase(System.getProperty("hmcl.hardware.fastfetch", "true")); |
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.