diff options
author | n-peugnet <n.peugnet@free.fr> | 2021-09-22 19:50:41 +0200 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2021-09-22 20:44:28 +0200 |
commit | cce3365003dba7c3ac2905f71aa284caf63a1c78 (patch) | |
tree | a2a9d320028a6dc3c5bb31bd4d88929816955f40 /repo.go | |
parent | a1b768438258bfd6c33573e156708f002c693ba2 (diff) | |
download | dna-backup-cce3365003dba7c3ac2905f71aa284caf63a1c78.tar.gz dna-backup-cce3365003dba7c3ac2905f71aa284caf63a1c78.zip |
fix for stream smaller than chunkSize
Diffstat (limited to 'repo.go')
-rw-r--r-- | repo.go | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -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] |