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:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user