mirror of
https://github.com/containers/image.git
synced 2025-04-18 19:44:05 +03:00
Fix "QF1009: probably want to use time.Time.Equal instead"
time.IsZero() is probably a bit slower, but relying on an explicit API should be better long-term. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
parent
ae3a9aaa40
commit
ccf60336a2
@ -35,9 +35,9 @@ type bodyReader struct {
|
||||
|
||||
body io.ReadCloser // The currently open connection we use to read data, or nil if there is nothing to read from / close.
|
||||
lastRetryOffset int64 // -1 if N/A
|
||||
lastRetryTime time.Time // time.Time{} if N/A
|
||||
lastRetryTime time.Time // IsZero() if N/A
|
||||
offset int64 // Current offset within the blob
|
||||
lastSuccessTime time.Time // time.Time{} if N/A
|
||||
lastSuccessTime time.Time // IsZero() if N/A
|
||||
}
|
||||
|
||||
// newBodyReader creates a bodyReader for request path in c.
|
||||
@ -207,9 +207,9 @@ func (br *bodyReader) Read(p []byte) (int, error) {
|
||||
}
|
||||
|
||||
// millisecondsSinceOptional is like currentTime.Sub(tm).Milliseconds, but it returns a floating-point value.
|
||||
// If tm is time.Time{}, it returns math.NaN()
|
||||
// If tm.IsZero(), it returns math.NaN()
|
||||
func millisecondsSinceOptional(currentTime time.Time, tm time.Time) float64 {
|
||||
if tm == (time.Time{}) {
|
||||
if tm.IsZero() {
|
||||
return math.NaN()
|
||||
}
|
||||
return float64(currentTime.Sub(tm).Nanoseconds()) / 1_000_000.0
|
||||
@ -229,7 +229,7 @@ func (br *bodyReader) errorIfNotReconnecting(originalErr error, redactedURL stri
|
||||
logrus.Infof("Reading blob body from %s failed (%v), reconnecting after %d bytes…", redactedURL, originalErr, progress)
|
||||
return nil
|
||||
}
|
||||
if br.lastRetryTime == (time.Time{}) {
|
||||
if br.lastRetryTime.IsZero() {
|
||||
logrus.Infof("Reading blob body from %s failed (%v), reconnecting (first reconnection)…", redactedURL, originalErr)
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user