From b4d2766af06a20a8f000347be0a20de47bddf442 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Mon, 30 Aug 2021 16:35:40 +0200 Subject: fix: last partial chunk is not added to recipe --- repo.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'repo.go') diff --git a/repo.go b/repo.go index 457dadd..cfb5580 100644 --- a/repo.go +++ b/repo.go @@ -296,8 +296,12 @@ func (r *Repo) matchStream(stream io.Reader, fingerprints FingerprintMap) []Chun buff = make([]byte, 0, chunkSize) for i := 0; i < chunkSize && err == nil; i++ { b, err = bufStream.ReadByte() + buff = append(buff, b) hasher.Roll(b) } + if err == nil { + buff = make([]byte, 0, chunkSize) + } continue } if len(buff) == chunkSize { @@ -312,7 +316,8 @@ func (r *Repo) matchStream(stream io.Reader, fingerprints FingerprintMap) []Chun } } if len(buff) > 0 { - chunks = append(chunks, NewTempChunk(buff)) + log.Printf("Add new partial chunk of size: %d\n", len(buff)) + chunks = append(chunks, NewTempChunk(buff[:chunkSize])) } return chunks } -- cgit v1.2.3