performance: change I/O buffer size

This commit is contained in:
lb-a
2026-04-29 23:56:05 +02:00
parent 945695cea7
commit 7a27845e75

View File

@@ -246,7 +246,7 @@ func (d *Downloader) file(ctx context.Context, sourceURL, outputPath string, all
)
defer bar.SetTotal(-1, true)
}
buf := make([]byte, 256*1024)
buf := make([]byte, downloadBufferSize)
totalWritten := int64(0)
for {
n, readErr := reader.Read(buf)
@@ -271,7 +271,7 @@ func (d *Downloader) file(ctx context.Context, sourceURL, outputPath string, all
return err
}
} else {
written, copyErr := io.Copy(out, reader)
written, copyErr := io.CopyBuffer(out, reader, make([]byte, downloadBufferSize))
if copyErr != nil {
return copyErr
}