From db36014654d0b8d4ff25f0b8f2693020dd07e167 Mon Sep 17 00:00:00 2001 From: Ching Kuo Date: Wed, 5 Aug 2026 11:50:11 +0900 Subject: [PATCH] fix(ObjectStore): reset multipart upload byte counter on retry writeMultiPart() initializes $totalWritten once outside the retry loop, so bytes from a failed first attempt accumulate into the second attempt. Since $state is never resumed, each retry rewinds the stream and re-uploads the whole object from scratch, making before_complete compare roughly twice the object size against the expected size. The retry then always fails with "Incomplete multi part upload, expected X bytes, wrote 2X" and the upload is aborted. Reset the counter per attempt so the size check validates only the bytes written by the current attempt. Fixes #59505 Signed-off-by: Ching Kuo Assisted-by: Claude Code:claude-fable-5 --- lib/private/Files/ObjectStore/S3ObjectTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/Files/ObjectStore/S3ObjectTrait.php b/lib/private/Files/ObjectStore/S3ObjectTrait.php index d2f43ca65f737..633345e7ac63a 100644 --- a/lib/private/Files/ObjectStore/S3ObjectTrait.php +++ b/lib/private/Files/ObjectStore/S3ObjectTrait.php @@ -145,10 +145,10 @@ protected function writeMultiPart(string $urn, StreamInterface $stream, array $m $exception = null; $state = null; $size = $stream->getSize(); - $totalWritten = 0; // retry multipart upload once with concurrency at half on failure while (!$uploaded && $attempts <= 1) { + $totalWritten = 0; $uploader = new MultipartUploader($this->getConnection(), $stream, [ 'bucket' => $this->bucket, 'concurrency' => $concurrency,