diff options
author | n-peugnet <n.peugnet@free.fr> | 2021-08-30 16:35:40 +0200 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2021-08-30 16:35:40 +0200 |
commit | b4d2766af06a20a8f000347be0a20de47bddf442 (patch) | |
tree | bea620b452bcde681bbc4cabf71d86d095c9d56f | |
parent | ad38e12c15af10a73447196ac0b0f1a5df8bf865 (diff) | |
download | dna-backup-b4d2766af06a20a8f000347be0a20de47bddf442.tar.gz dna-backup-b4d2766af06a20a8f000347be0a20de47bddf442.zip |
fix: last partial chunk is not added to recipe
-rw-r--r-- | repo.go | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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 } |