checker: rewrite ReadData to stream packs

This commit is contained in:
Michael Eischer
2021-08-20 16:15:40 +02:00
parent f40abd92fa
commit f1e58e7c7f
4 changed files with 119 additions and 79 deletions

View File

@@ -27,7 +27,7 @@ import (
"golang.org/x/sync/errgroup"
)
const maxStreamBufferSize = 4 * 1024 * 1024
const MaxStreamBufferSize = 4 * 1024 * 1024
// Repository is used to access a repository in a backend.
type Repository struct {
@@ -808,8 +808,8 @@ func StreamPack(ctx context.Context, beLoad BackendLoadFn, key *crypto.Key, pack
// stream blobs in pack
err := beLoad(ctx, h, int(dataEnd-dataStart), int64(dataStart), func(rd io.Reader) error {
bufferSize := int(dataEnd - dataStart)
if bufferSize > maxStreamBufferSize {
bufferSize = maxStreamBufferSize
if bufferSize > MaxStreamBufferSize {
bufferSize = MaxStreamBufferSize
}
bufRd := bufio.NewReaderSize(rd, bufferSize)
currentBlobEnd := dataStart