From e6470d998cf0a63fce49f1bd0d167887be84166f Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 1 Aug 2025 15:25:22 +0100 Subject: [PATCH] azureblob: fix double accounting for multipart uploads - fixes #8718 Before this change multipart uploads using OpenChunkWriter would account for twice the space used. This fixes the problem by adjusting the accounting delay. --- backend/azureblob/azureblob.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/azureblob/azureblob.go b/backend/azureblob/azureblob.go index 2f7c8c927..71166f3b3 100644 --- a/backend/azureblob/azureblob.go +++ b/backend/azureblob/azureblob.go @@ -51,6 +51,7 @@ import ( "github.com/rclone/rclone/lib/env" "github.com/rclone/rclone/lib/multipart" "github.com/rclone/rclone/lib/pacer" + "github.com/rclone/rclone/lib/pool" "golang.org/x/sync/errgroup" ) @@ -2670,6 +2671,13 @@ func (w *azChunkWriter) WriteChunk(ctx context.Context, chunkNumber int, reader 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(2) + } + // Upload the block, with MD5 for check m := md5.New() currentChunkSize, err := io.Copy(m, reader)