From f992742404c258dc375096973398f7e6a9045f16 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 24 Aug 2023 17:15:18 +0100 Subject: [PATCH] s3: fix accounting for multpart uploads --- backend/s3/s3.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/s3/s3.go b/backend/s3/s3.go index c5ca85db7..18171904e 100644 --- a/backend/s3/s3.go +++ b/backend/s3/s3.go @@ -55,6 +55,7 @@ import ( "github.com/rclone/rclone/lib/encoder" "github.com/rclone/rclone/lib/multipart" "github.com/rclone/rclone/lib/pacer" + "github.com/rclone/rclone/lib/pool" "github.com/rclone/rclone/lib/readers" "github.com/rclone/rclone/lib/rest" "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) 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 // currently there is no way to calculate the md5 without reading the chunk a 2nd time (1st read is in uploadMultipart)