fs: Async buffer: use ReadFill to fill the chunks and increase to 1MB
This commit is contained in:
parent
493da54113
commit
7fa687b3e1
3 changed files with 3 additions and 3 deletions
|
@ -348,7 +348,7 @@ func NewAccount(in io.ReadCloser, obj Object) *Account {
|
||||||
//
|
//
|
||||||
// If the file is above a certain size it adds an Async reader
|
// If the file is above a certain size it adds an Async reader
|
||||||
func NewAccountSizeNameWithBuffer(in io.ReadCloser, size int64, name string) *Account {
|
func NewAccountSizeNameWithBuffer(in io.ReadCloser, size int64, name string) *Account {
|
||||||
const bufSize = 128 * 1024
|
const bufSize = 1024 * 1024
|
||||||
var buffers int
|
var buffers int
|
||||||
if size >= int64(Config.BufferSize) {
|
if size >= int64(Config.BufferSize) {
|
||||||
buffers = int(int64(Config.BufferSize) / bufSize)
|
buffers = int(int64(Config.BufferSize) / bufSize)
|
||||||
|
|
|
@ -183,7 +183,7 @@ func (b *buffer) isEmpty() bool {
|
||||||
// Any error encountered during the read is returned.
|
// Any error encountered during the read is returned.
|
||||||
func (b *buffer) read(rd io.Reader) error {
|
func (b *buffer) read(rd io.Reader) error {
|
||||||
var n int
|
var n int
|
||||||
n, b.err = rd.Read(b.buf[0:b.size])
|
n, b.err = ReadFill(rd, b.buf[0:b.size])
|
||||||
b.buf = b.buf[0:n]
|
b.buf = b.buf[0:n]
|
||||||
b.offset = 0
|
b.offset = 0
|
||||||
return b.err
|
return b.err
|
||||||
|
|
|
@ -20,7 +20,7 @@ func TestAsyncReader(t *testing.T) {
|
||||||
|
|
||||||
var dst = make([]byte, 100)
|
var dst = make([]byte, 100)
|
||||||
n, err := ar.Read(dst)
|
n, err := ar.Read(dst)
|
||||||
require.NoError(t, err)
|
assert.Equal(t, io.EOF, err)
|
||||||
assert.Equal(t, 10, n)
|
assert.Equal(t, 10, n)
|
||||||
|
|
||||||
n, err = ar.Read(dst)
|
n, err = ar.Read(dst)
|
||||||
|
|
Loading…
Add table
Reference in a new issue