Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

backend/s3: Fail fast multipart upload

Michał Matczuk19a4d74ee7f4
diff --git a/backend/s3/s3.go b/backend/s3/s3.go
index 07bc8780b..99641874b 100644
--- a/backend/s3/s3.go
+++ b/backend/s3/s3.go
@@ -2165,6 +2165,12 @@ func (o *Object) uploadMultipart(ctx context.Context, req *s3.PutObjectInput, si
buf = make([]byte, partSize)
}
+ // Fail fast, in case an errgroup managed function returns an error
+ // gCtx is cancelled. There is no point in uploading all the other parts.
+ if gCtx.Err() != nil {
+ break
+ }
+
// Read the chunk
var n int
n, err = readers.ReadFill(in, buf) // this can never return 0, nil