-
Notifications
You must be signed in to change notification settings - Fork 193
CompleteMultipartUpload is idempotent #2593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -120,7 +120,9 @@ public MultipartUpload createMultipartUpload( | |||||||||
| tags, | ||||||||||
| null, | ||||||||||
| checksumType, | ||||||||||
| checksumAlgorithm); | ||||||||||
| checksumAlgorithm, | ||||||||||
| false | ||||||||||
| ); | ||||||||||
| lockStore.putIfAbsent(uploadId, new Object()); | ||||||||||
| writeMetafile(bucket, multipartUploadInfo); | ||||||||||
|
|
||||||||||
|
|
@@ -139,7 +141,7 @@ public List<MultipartUpload> listMultipartUploads(BucketMetadata bucketMetadata, | |||||||||
| path -> { | ||||||||||
| var fileName = path.getFileName().toString(); | ||||||||||
| var uploadMetadata = getUploadMetadata(bucketMetadata, UUID.fromString(fileName)); | ||||||||||
| if (uploadMetadata != null) { | ||||||||||
| if (uploadMetadata != null && !uploadMetadata.completed()) { | ||||||||||
| return uploadMetadata.upload(); | ||||||||||
| } else { | ||||||||||
| return null; | ||||||||||
|
|
@@ -161,10 +163,18 @@ public MultipartUploadInfo getMultipartUploadInfo( | |||||||||
| return getUploadMetadata(bucketMetadata, uploadId); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| public MultipartUpload getMultipartUpload(BucketMetadata bucketMetadata, UUID uploadId) { | ||||||||||
| public MultipartUpload getMultipartUpload(BucketMetadata bucketMetadata, UUID uploadId, boolean includeCompleted) { | ||||||||||
| var uploadMetadata = getUploadMetadata(bucketMetadata, uploadId); | ||||||||||
| if (uploadMetadata != null) { | ||||||||||
| return uploadMetadata.upload(); | ||||||||||
| if (includeCompleted) { | ||||||||||
| return uploadMetadata.upload(); | ||||||||||
| } else { | ||||||||||
| if (uploadMetadata.completed()) { | ||||||||||
| throw new IllegalArgumentException("No active MultipartUpload found with uploadId: " + uploadId); | ||||||||||
| } else { | ||||||||||
| return uploadMetadata.upload(); | ||||||||||
| } | ||||||||||
| } | ||||||||||
| } else { | ||||||||||
| throw new IllegalArgumentException("No MultipartUpload found with uploadId: " + uploadId); | ||||||||||
| } | ||||||||||
|
|
@@ -243,12 +253,16 @@ public CompleteMultipartUploadResult completeMultipartUpload( | |||||||||
| uploadInfo.storageClass(), | ||||||||||
| ChecksumType.COMPOSITE | ||||||||||
| ); | ||||||||||
| FileUtils.deleteDirectory(partFolder.toFile()); | ||||||||||
| //delete parts and update MultipartInfo | ||||||||||
|
||||||||||
| //delete parts and update MultipartInfo | |
| // Delete individual part files but preserve multipart upload metadata for idempotent operations |
Copilot
AI
Aug 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment should use proper capitalization: 'Delete parts and update MultipartInfo'.
| //delete parts and update MultipartInfo | |
| // Delete parts and update MultipartInfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This null check for
completed()is inconsistent with the Boolean type. Sincecompletedis nullable Boolean, this should use!Boolean.TRUE.equals(uploadMetadata.completed())to properly handle null values.