diff --git a/internal/oplog/oplog.go b/internal/oplog/oplog.go index 4eedc5a90..c403f42ca 100644 --- a/internal/oplog/oplog.go +++ b/internal/oplog/oplog.go @@ -3,7 +3,6 @@ package oplog import ( - "bufio" "encoding/json" "os" "path/filepath" @@ -92,21 +91,18 @@ func Read(configPath, filename string, limit int) ([]Entry, error) { defer f.Close() var all []Entry - scanner := bufio.NewScanner(f) - for scanner.Scan() { - line := scanner.Bytes() - if len(line) == 0 { - continue - } + dec := json.NewDecoder(f) + for dec.More() { var e Entry - if err := json.Unmarshal(line, &e); err != nil { - continue // skip malformed lines + if err := dec.Decode(&e); err != nil { + // Skip malformed entries — advance past the bad line + if dec.More() { + continue + } + break } all = append(all, e) } - if err := scanner.Err(); err != nil { - return nil, err - } // Reverse to newest-first for i, j := 0, len(all)-1; i < j; i, j = i+1, j-1 {