Add --buffer-size parameter to control buffer size for copy

This commit is contained in:
Nick Craig-Wood
2017-02-14 22:36:37 +00:00
parent 541929258b
commit 493da54113
3 changed files with 19 additions and 4 deletions
+8 -4
View File
@@ -348,11 +348,15 @@ func NewAccount(in io.ReadCloser, obj Object) *Account {
//
// If the file is above a certain size it adds an Async reader
func NewAccountSizeNameWithBuffer(in io.ReadCloser, size int64, name string) *Account {
const bufSize = 128 * 1024
var buffers int
if size >= int64(Config.BufferSize) {
buffers = int(int64(Config.BufferSize) / bufSize)
} else {
buffers = int(size / bufSize)
}
// On big files add a buffer
if size > 10<<20 {
const memUsed = 16 * 1024 * 1024
const bufSize = 128 * 1024
const buffers = memUsed / bufSize
if buffers > 0 {
newIn, err := newAsyncReader(in, buffers, bufSize)
if err != nil {
Errorf(name, "Failed to make buffer: %v", err)