mirror of
https://git.sr.ht/~joren/streamrip-go
synced 2026-06-17 15:05:39 +02:00
performance: change I/O buffer size
This commit is contained in:
@@ -246,7 +246,7 @@ func (d *Downloader) file(ctx context.Context, sourceURL, outputPath string, all
|
|||||||
)
|
)
|
||||||
defer bar.SetTotal(-1, true)
|
defer bar.SetTotal(-1, true)
|
||||||
}
|
}
|
||||||
buf := make([]byte, 256*1024)
|
buf := make([]byte, downloadBufferSize)
|
||||||
totalWritten := int64(0)
|
totalWritten := int64(0)
|
||||||
for {
|
for {
|
||||||
n, readErr := reader.Read(buf)
|
n, readErr := reader.Read(buf)
|
||||||
@@ -271,7 +271,7 @@ func (d *Downloader) file(ctx context.Context, sourceURL, outputPath string, all
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
written, copyErr := io.Copy(out, reader)
|
written, copyErr := io.CopyBuffer(out, reader, make([]byte, downloadBufferSize))
|
||||||
if copyErr != nil {
|
if copyErr != nil {
|
||||||
return copyErr
|
return copyErr
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user