Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions StabilityMatrix.Core/Helper/HardwareInfo/HardwareHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private static IEnumerable<GpuInfo> IterGpuInfoWindows()
[SupportedOSPlatform("linux")]
private static IEnumerable<GpuInfo> IterGpuInfoLinux()
{
var output = RunBashCommand("lspci | grep VGA");
var output = RunBashCommand("lspci | grep -E 'VGA|3D'");
var gpuLines = output.Split("\n");

var gpuIndex = 0;
Expand All @@ -87,10 +87,10 @@ private static IEnumerable<GpuInfo> IterGpuInfoLinux()
string? name = null;

// Parse output with regex
var match = Regex.Match(gpuOutput, @"VGA compatible controller: ([^\n]*)");
var match = Regex.Match(gpuOutput, @"(VGA compatible controller|3D controller): ([^\n]*)");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The regex now includes both 'VGA compatible controller' and '3D controller'. Since the second group captures the name, ensure this change doesn't inadvertently affect other parts of the application that rely on this regex. Consider adding a unit test to specifically validate the parsing of '3D controller' outputs.

if (match.Success)
{
name = match.Groups[1].Value.Trim();
name = match.Groups[2].Value.Trim();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The group index has been updated from 1 to 2 to accommodate the new regex pattern. This is correct, but it's crucial to ensure that this change doesn't break any existing logic that relies on the captured GPU name. Consider adding a comment explaining why the index was changed.

name = match.Groups[2].Value.Trim(); // Group 2 captures the GPU name after the controller type

}

match = Regex.Match(gpuOutput, @"prefetchable\) \[size=(\\d+)M\]");
Expand Down