aboutsummaryrefslogtreecommitdiff
path: root/repo.go
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2021-09-22 19:50:41 +0200
committern-peugnet <n.peugnet@free.fr>2021-09-22 20:44:28 +0200
commitcce3365003dba7c3ac2905f71aa284caf63a1c78 (patch)
treea2a9d320028a6dc3c5bb31bd4d88929816955f40 /repo.go
parenta1b768438258bfd6c33573e156708f002c693ba2 (diff)
downloaddna-backup-cce3365003dba7c3ac2905f71aa284caf63a1c78.tar.gz
dna-backup-cce3365003dba7c3ac2905f71aa284caf63a1c78.zip
fix for stream smaller than chunkSize
Diffstat (limited to 'repo.go')
-rw-r--r--repo.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/repo.go b/repo.go
index ac7fe3e..f36bb65 100644
--- a/repo.go
+++ b/repo.go
@@ -595,9 +595,13 @@ func (r *Repo) matchStream(stream io.Reader, version int) []Chunk {
var err error
bufStream := bufio.NewReaderSize(stream, r.chunkSize*2)
buff := make([]byte, r.chunkSize, r.chunkSize*2)
+ storeQueue := make(chan chunkData, 10)
+ storeEnd := make(chan bool)
+ go r.storageWorker(version, storeQueue, storeEnd)
if n, err := io.ReadFull(stream, buff); n < r.chunkSize {
- if err == io.EOF {
- chunks = append(chunks, NewTempChunk(buff[:n]))
+ if err == io.ErrUnexpectedEOF {
+ c, _ := r.encodeTempChunk(NewTempChunk(buff[:n]), version, &last, storeQueue)
+ chunks = append(chunks, c)
return chunks
} else {
logger.Panicf("matching stream, read only %d bytes with error '%s'", n, err)
@@ -605,9 +609,6 @@ func (r *Repo) matchStream(stream io.Reader, version int) []Chunk {
}
hasher := rabinkarp64.NewFromPol(r.pol)
hasher.Write(buff)
- storeQueue := make(chan chunkData, 10)
- storeEnd := make(chan bool)
- go r.storageWorker(version, storeQueue, storeEnd)
for err != io.EOF {
h := hasher.Sum64()
chunkId, exists := r.fingerprints[h]