From 71a173472b6e5365a1d35d16aed81f12de0e8a6d Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 30 Jul 2026 17:41:01 +0100 Subject: [PATCH] dropbox: use much less memory when uploading small files - fixes #9685 Since batch mode became the default all uploads go through uploadChunked, which allocated a full chunk-size retry buffer (48 MiB by default) regardless of the file size. With the `--transfers 32` recommended for small file uploads that is ~1.5 GiB of buffer to upload tiny files. Size the buffer to the file size when it is known and smaller than a chunk. --- backend/dropbox/dropbox.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/dropbox/dropbox.go b/backend/dropbox/dropbox.go index 556a3c520..bb2f62449 100644 --- a/backend/dropbox/dropbox.go +++ b/backend/dropbox/dropbox.go @@ -2042,7 +2042,11 @@ func (o *Object) uploadChunked(ctx context.Context, in0 io.Reader, commitInfo *f // write chunks in := readers.NewCountingReader(in0) - buf := make([]byte, int(chunkSize)) + bufSize := chunkSize + if size >= 0 && size < bufSize { + bufSize = size + } + buf := make([]byte, int(bufSize)) cursor := files.UploadSessionCursor{ SessionId: res.SessionId, Offset: 0,