diff options
author | n-peugnet <n.peugnet@free.fr> | 2021-08-31 12:05:29 +0200 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2021-08-31 12:05:29 +0200 |
commit | c481eb2b44adf50b62de3b9e3355f64973967d52 (patch) | |
tree | 34a218c926f6aa6420c8abfcf703262e6148c0ed /repo.go | |
parent | 36da6832dce67da09d7bcee1a6ab2312e515cb0a (diff) | |
download | dna-backup-c481eb2b44adf50b62de3b9e3355f64973967d52.tar.gz dna-backup-c481eb2b44adf50b62de3b9e3355f64973967d52.zip |
do not fill partial cunks with padding
this way a partial chunk may have less superfeatures than
a complete one
Diffstat (limited to 'repo.go')
-rw-r--r-- | repo.go | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -145,7 +145,7 @@ func chunkStream(stream io.Reader, chunks chan<- []byte) { } } if prev != chunkSize { - chunks <- buff + chunks <- buff[:prev] } close(chunks) } @@ -290,9 +290,7 @@ func (r *Repo) matchStream(stream io.Reader, fingerprints FingerprintMap) []Chun if len(buff) > chunkSize && len(buff) < chunkSize*2 { size := len(buff) - chunkSize log.Println("Add new partial chunk of size:", size) - tmp := make([]byte, 0, chunkSize) - tmp = append(tmp, buff[:size]...) - chunks = append(chunks, NewTempChunk(tmp[:chunkSize])) + chunks = append(chunks, NewTempChunk(buff[:size])) } log.Printf("Add existing chunk: %d\n", chunkId) chunks = append(chunks, NewChunkFile(r, chunkId)) @@ -321,10 +319,10 @@ func (r *Repo) matchStream(stream io.Reader, fingerprints FingerprintMap) []Chun log.Println("Add new chunk") chunks = append(chunks, NewTempChunk(buff[:chunkSize])) log.Println("Add new partial chunk of size:", len(buff)-chunkSize) - chunks = append(chunks, NewTempChunk(buff[chunkSize:chunkSize*2])) + chunks = append(chunks, NewTempChunk(buff[chunkSize:])) } else if len(buff) > 0 { log.Println("Add new partial chunk of size:", len(buff)) - chunks = append(chunks, NewTempChunk(buff[chunkSize:chunkSize*2])) + chunks = append(chunks, NewTempChunk(buff)) } return chunks } |