aboutsummaryrefslogtreecommitdiff
path: root/repo.go
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2021-08-30 16:35:40 +0200
committern-peugnet <n.peugnet@free.fr>2021-08-30 16:35:40 +0200
commitb4d2766af06a20a8f000347be0a20de47bddf442 (patch)
treebea620b452bcde681bbc4cabf71d86d095c9d56f /repo.go
parentad38e12c15af10a73447196ac0b0f1a5df8bf865 (diff)
downloaddna-backup-b4d2766af06a20a8f000347be0a20de47bddf442.tar.gz
dna-backup-b4d2766af06a20a8f000347be0a20de47bddf442.zip
fix: last partial chunk is not added to recipe
Diffstat (limited to 'repo.go')
-rw-r--r--repo.go7
1 files changed, 6 insertions, 1 deletions
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
}