fix: track after buffer write

This commit is contained in:
Derrick Hammer 2024-02-28 12:37:32 -05:00
parent c984d72cfd
commit 0b000bfc89
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 3 additions and 3 deletions

View File

@ -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