mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-23 09:31:02 +01:00
fix(uptime): set to 0 instead of returning error on overflow check
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
@@ -37,11 +36,13 @@ func (info *HealthInfo) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
// overflow check
|
||||
if math.MaxInt64/time.Microsecond < time.Duration(v.Latency) {
|
||||
return fmt.Errorf("latency overflow: %d", v.Latency)
|
||||
// Check if latency (in microseconds) would overflow when converted to nanoseconds
|
||||
if v.Latency > math.MaxInt64/int64(time.Microsecond) {
|
||||
v.Latency = 0
|
||||
}
|
||||
if math.MaxInt64/time.Millisecond < time.Duration(v.Uptime) {
|
||||
return fmt.Errorf("uptime overflow: %d", v.Uptime)
|
||||
// Check if uptime (in milliseconds) would overflow when converted to nanoseconds
|
||||
if v.Uptime > math.MaxInt64/int64(time.Millisecond) {
|
||||
v.Uptime = 0
|
||||
}
|
||||
|
||||
info.Status = types.NewHealthStatusFromString(v.Status)
|
||||
|
||||
Reference in New Issue
Block a user