Skip to content

Commit

Permalink
ignore permission errors and try to continue anyway
Browse files Browse the repository at this point in the history
  • Loading branch information
markusressel committed Oct 3, 2023
1 parent 92b0d1c commit 5504fb8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions internal/fans/hwmon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5504fb8

Please sign in to comment.