querylog_search.go (AdGuardHome-0.104.1) | : | querylog_search.go (AdGuardHome-0.104.3) | ||
---|---|---|---|---|
package querylog | package querylog | |||
import ( | import ( | |||
"errors" | ||||
"io" | "io" | |||
"time" | "time" | |||
"github.com/AdguardTeam/AdGuardHome/internal/util" | "github.com/AdguardTeam/AdGuardHome/internal/util" | |||
"github.com/AdguardTeam/golibs/log" | "github.com/AdguardTeam/golibs/log" | |||
) | ) | |||
// search - searches log entries in the query log using specified parameters | // search - searches log entries in the query log using specified parameters | |||
// returns the list of entries found + time of the oldest entry | // returns the list of entries found + time of the oldest entry | |||
func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) { | func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) { | |||
skipping to change at line 98 | skipping to change at line 97 | |||
if params.olderThan.IsZero() { | if params.olderThan.IsZero() { | |||
err = r.SeekStart() | err = r.SeekStart() | |||
} else { | } else { | |||
err = r.Seek(params.olderThan.UnixNano()) | err = r.Seek(params.olderThan.UnixNano()) | |||
if err == nil { | if err == nil { | |||
// Read to the next record right away | // Read to the next record right away | |||
// The one that was specified in the "oldest" param is no t needed, | // The one that was specified in the "oldest" param is no t needed, | |||
// we need only the one next to it | // we need only the one next to it | |||
_, err = r.ReadNext() | _, err = r.ReadNext() | |||
} else if errors.Is(err, ErrEndOfLog) { | ||||
// We've reached the end of the log. | ||||
return entries, time.Time{}, 0 | ||||
} | } | |||
} | } | |||
if err != nil { | if err != nil { | |||
log.Debug("Cannot Seek() to %v: %v", params.olderThan, err) | log.Debug("Cannot Seek() to %v: %v", params.olderThan, err) | |||
return entries, oldest, 0 | return entries, oldest, 0 | |||
} | } | |||
totalLimit := params.offset + params.limit | totalLimit := params.offset + params.limit | |||
total := 0 | total := 0 | |||
End of changes. 2 change blocks. | ||||
4 lines changed or deleted | 0 lines changed or added |