s3: fix accounting for multpart uploads

This commit is contained in:
Nick Craig-Wood 2023-08-24 17:15:18 +01:00
parent f2467d07aa
commit f992742404

View File

@ -55,6 +55,7 @@ import (
"github.com/rclone/rclone/lib/encoder" "github.com/rclone/rclone/lib/encoder"
"github.com/rclone/rclone/lib/multipart" "github.com/rclone/rclone/lib/multipart"
"github.com/rclone/rclone/lib/pacer" "github.com/rclone/rclone/lib/pacer"
"github.com/rclone/rclone/lib/pool"
"github.com/rclone/rclone/lib/readers" "github.com/rclone/rclone/lib/readers"
"github.com/rclone/rclone/lib/rest" "github.com/rclone/rclone/lib/rest"
"github.com/rclone/rclone/lib/version" "github.com/rclone/rclone/lib/version"
@ -5403,6 +5404,12 @@ func (w *s3ChunkWriter) WriteChunk(ctx context.Context, chunkNumber int, reader
err := fmt.Errorf("invalid chunk number provided: %v", chunkNumber) err := fmt.Errorf("invalid chunk number provided: %v", chunkNumber)
return -1, err return -1, err
} }
// Only account after the checksum reads have been done
if do, ok := reader.(pool.DelayAccountinger); ok {
// To figure out this number, do a transfer and if the accounted size is 0 or a
// multiple of what it should be, increase or decrease this number.
do.DelayAccounting(3)
}
// create checksum of buffer for integrity checking // create checksum of buffer for integrity checking
// currently there is no way to calculate the md5 without reading the chunk a 2nd time (1st read is in uploadMultipart) // currently there is no way to calculate the md5 without reading the chunk a 2nd time (1st read is in uploadMultipart)