From 5504fb816016234f7c423924040d7fec8e02ebb1 Mon Sep 17 00:00:00 2001 From: Markus Ressel Date: Tue, 3 Oct 2023 13:25:05 +0200 Subject: [PATCH] ignore permission errors and try to continue anyway --- internal/fans/hwmon.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/internal/fans/hwmon.go b/internal/fans/hwmon.go index 8ef02ec..3355466 100644 --- a/internal/fans/hwmon.go +++ b/internal/fans/hwmon.go @@ -161,9 +161,14 @@ func (fan *HwMonFan) IsPwmAuto() (bool, error) { func (fan *HwMonFan) SetPwmEnabled(value ControlMode) (err error) { err = util.WriteIntToFile(int(value), fan.Config.HwMon.PwmEnablePath) if err == nil { - currentValue, err := util.ReadIntFromFile(fan.Config.HwMon.PwmEnablePath) - if err != nil || ControlMode(currentValue) != value { - return fmt.Errorf("PWM mode stuck to %d", currentValue) + currentValue, err := fan.GetPwmEnabled() + if err != nil { + if errors.Is(err, os.ErrPermission) { + ui.Warning("Cannot read pwm_enable of fan '%s', pwm_enable state validation cannot work. Continuing assuming it worked.", fan.GetId()) + return nil + } else if ControlMode(currentValue) != value { + return fmt.Errorf("PWM mode stuck to %d", currentValue) + } } } return err