Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

fs: Async buffer: use ReadFill to fill the chunks and increase to 1MB

Nick Craig-Wood7fa687b3e1e0
diff --git a/fs/accounting.go b/fs/accounting.go
index 217fe6eed..40926f72f 100644
--- a/fs/accounting.go
+++ b/fs/accounting.go
@@ -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
func NewAccountSizeNameWithBuffer(in io.ReadCloser, size int64, name string) *Account {
- const bufSize = 128 * 1024
+ const bufSize = 1024 * 1024
var buffers int
if size >= int64(Config.BufferSize) {
buffers = int(int64(Config.BufferSize) / bufSize)
diff --git a/fs/buffer.go b/fs/buffer.go
index 724654b45..8a7a51431 100644
--- a/fs/buffer.go
+++ b/fs/buffer.go
@@ -183,7 +183,7 @@ func (b *buffer) isEmpty() bool {
// Any error encountered during the read is returned.
func (b *buffer) read(rd io.Reader) error {
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.offset = 0
return b.err
diff --git a/fs/buffer_test.go b/fs/buffer_test.go
index 5528e9992..466e7d6be 100644
--- a/fs/buffer_test.go
+++ b/fs/buffer_test.go
@@ -20,7 +20,7 @@ func TestAsyncReader(t *testing.T) {
var dst = make([]byte, 100)
n, err := ar.Read(dst)
- require.NoError(t, err)
+ assert.Equal(t, io.EOF, err)
assert.Equal(t, 10, n)
n, err = ar.Read(dst)