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.
This commit is contained in:
Nick Craig-Wood
2026-07-30 19:30:38 +01:00
parent 71a173472b
commit e6a2347bb3
+6 -1
View File
@@ -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()