Skip to content

Commit 09cd8d0

Browse files
committed
add check for battery array length (#1076)
1 parent 36f1a0c commit 09cd8d0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

beszel/internal/agent/battery.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "github.com/distatus/battery"
55
// getBatteryStats returns the current battery percent and charge state
66
func getBatteryStats() (batteryPercent uint8, batteryState uint8, err error) {
77
batteries, err := battery.GetAll()
8-
if err != nil {
8+
if err != nil || len(batteries) == 0 {
99
return batteryPercent, batteryState, err
1010
}
1111
totalCapacity := float64(0)

0 commit comments

Comments
 (0)