From b3ad3afb80985bab8fc70a117667b3815efcdeb3 Mon Sep 17 00:00:00 2001 From: mathusan paramanithy Date: Sun, 20 Sep 2026 23:47:55 +0100 Subject: [PATCH 1/2] fix(DeviceMetrics.fs): Added exception handling for cpu temp --- .github/workflows/test.yml | 2 +- src/Pryde.Data/DeviceMetrics.fs | 32 +++++++++++++++++--------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8e0ad23..ab600e5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,4 +25,4 @@ jobs: run: dotnet build --no-restore --configuration Release - name: Run Unit Tests - run: dotnet test --no-build --configuration Release --verbosity normal + run: dotnet test --no-build --configuration Release --verb osity normal diff --git a/src/Pryde.Data/DeviceMetrics.fs b/src/Pryde.Data/DeviceMetrics.fs index 9358dd3..295eb8c 100644 --- a/src/Pryde.Data/DeviceMetrics.fs +++ b/src/Pryde.Data/DeviceMetrics.fs @@ -7,22 +7,24 @@ open LibreHardwareMonitor.Hardware module DeviceMetrics = let getCpuTemperature () : float option = - let computer = Computer() - computer.IsCpuEnabled <- true - computer.Open() - - let mutable result = None try - for hardware in computer.Hardware do - if hardware.HardwareType = HardwareType.Cpu then - hardware.Update() - for sensor in hardware.Sensors do - if sensor.SensorType = SensorType.Temperature && sensor.Name.Contains("Package") then - result <- sensor.Value |> Option.ofNullable |> Option.map float - finally - computer.Close() - result - + let computer = Computer() + computer.IsCpuEnabled <- true + computer.Open() + + let mutable result = None + try + for hardware in computer.Hardware do + if hardware.HardwareType = HardwareType.Cpu then + hardware.Update() + for sensor in hardware.Sensors do + if sensor.SensorType = SensorType.Temperature && sensor.Name.Contains("Package") then + result <- sensor.Value |> Option.ofNullable |> Option.map float + finally + computer.Close() + result + with + | _ -> None let getUptime () : System.TimeSpan = use searcher = new ManagementObjectSearcher("SELECT LastBootUpTime FROM Win32_OperatingSystem") use results = searcher.Get() From 7702d61d342182a5fd25f5950ecf16281a28a7a8 Mon Sep 17 00:00:00 2001 From: mathusan paramanithy Date: Sun, 20 Sep 2026 23:52:19 +0100 Subject: [PATCH 2/2] fix(test.yml): Fixed unit test startup command spelling error --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ab600e5..8e0ad23 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,4 +25,4 @@ jobs: run: dotnet build --no-restore --configuration Release - name: Run Unit Tests - run: dotnet test --no-build --configuration Release --verb osity normal + run: dotnet test --no-build --configuration Release --verbosity normal