From e6a2347bb39e5250b8a59449a170ebf358d5e69f Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 30 Jul 2026 17:41:18 +0100 Subject: [PATCH] dropbox: remove an unnecessary API call when uploading small files - fixes #9686 The session close flag was only computed after each append, so a known-size upload which fits in a single chunk sent all its data and then issued a zero-payload append purely to close the session - one wasted round trip per small file on the default batched upload path. Set the close flag before the first append when the size is known to fit in one chunk. --- backend/dropbox/dropbox.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/dropbox/dropbox.go b/backend/dropbox/dropbox.go index bb2f62449..11a3360ac 100644 --- a/backend/dropbox/dropbox.go +++ b/backend/dropbox/dropbox.go @@ -2051,7 +2051,12 @@ func (o *Object) uploadChunked(ctx context.Context, in0 io.Reader, commitInfo *f SessionId: res.SessionId, Offset: 0, } - appendArg := files.UploadSessionAppendArg{Cursor: &cursor} + appendArg := files.UploadSessionAppendArg{ + Cursor: &cursor, + // A known-size upload which fits in a single chunk can close the + // session with its only append, saving an empty append request + Close: size >= 0 && size <= chunkSize, + } for currentChunk := 1; ; currentChunk++ { cursor.Offset = in.BytesRead()