From 0b000bfc8955ca278458420ecae1411cdaca73de Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 28 Feb 2024 12:37:32 -0500 Subject: [PATCH] fix: track after buffer write --- bao/bao.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bao/bao.go b/bao/bao.go index 4a9c73a..916a76d 100644 --- a/bao/bao.go +++ b/bao/bao.go @@ -63,14 +63,14 @@ func (v *Verifier) Read(p []byte) (int, error) { return n, errors.Join(ErrVerifyFailed, err) } + v.read += uint64(bytesRead) + v.buffer.Write(buf[:bytesRead]) // Append new data to the buffer + timeEnd := time.Now() v.verifyTime += timeEnd.Sub(timeStart) averageVerifyTime := v.verifyTime / time.Duration(v.read/VERIFY_CHUNK_SIZE) v.logger.Debug("Verification time", zap.Duration("duration", timeEnd.Sub(timeStart)), zap.Duration("average", averageVerifyTime)) - v.read += uint64(bytesRead) - v.buffer.Write(buf[:bytesRead]) // Append new data to the buffer - if err == io.EOF { // If EOF, break the loop as no more data can be read break