Skip to content
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

S3ErrorType.multipart renamed to S3ErrorType.MultipartError #721

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Sources/Soto/Extensions/S3/S3+multipart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import NIOPosix
import SotoCore

extension S3ErrorType {
public enum multipart: Error {
public enum MultipartError: Error {
/// CreateMultipartUpload did not return an uploadId
case noUploadId
/// Copy Source in multipartCopy has no content length
Expand Down Expand Up @@ -77,7 +77,7 @@ extension S3 {
)
let object = try await headObject(headRequest, logger: logger)
guard let contentLength = object.contentLength, contentLength > 0 else {
throw S3ErrorType.multipart.downloadEmpty(message: "Content length is unexpectedly zero")
throw S3ErrorType.MultipartError.downloadEmpty(message: "Content length is unexpectedly zero")
}

try await withThrowingTaskGroup(of: (Int, ByteBuffer).self) { group in
Expand Down Expand Up @@ -392,7 +392,7 @@ extension S3 {
let request: CreateMultipartUploadRequest = .init(acl: input.acl, bucket: input.bucket, cacheControl: input.cacheControl, contentDisposition: input.contentDisposition, contentEncoding: input.contentEncoding, contentLanguage: input.contentLanguage, contentType: input.contentType, expectedBucketOwner: input.expectedBucketOwner, expires: input.expires, grantFullControl: input.grantFullControl, grantRead: input.grantRead, grantReadACP: input.grantReadACP, grantWriteACP: input.grantWriteACP, key: input.key, metadata: input.metadata, objectLockLegalHoldStatus: input.objectLockLegalHoldStatus, objectLockMode: input.objectLockMode, objectLockRetainUntilDate: input.objectLockRetainUntilDate, requestPayer: input.requestPayer, serverSideEncryption: input.serverSideEncryption, sseCustomerAlgorithm: input.sseCustomerAlgorithm, sseCustomerKey: input.sseCustomerKey, sseCustomerKeyMD5: input.sseCustomerKeyMD5, ssekmsEncryptionContext: input.ssekmsEncryptionContext, ssekmsKeyId: input.ssekmsKeyId, storageClass: input.storageClass, tagging: input.tagging, websiteRedirectLocation: input.websiteRedirectLocation)
let uploadResponse = try await createMultipartUpload(request, logger: logger)
guard let uploadId = uploadResponse.uploadId else {
throw S3ErrorType.multipart.noUploadId
throw S3ErrorType.MultipartError.noUploadId
}

do {
Expand Down Expand Up @@ -470,7 +470,7 @@ extension S3 {
// initialize multipart upload
let upload = try await createMultipartUpload(input, logger: logger)
guard let uploadId = upload.uploadId else {
throw S3ErrorType.multipart.noUploadId
throw S3ErrorType.MultipartError.noUploadId
}

do {
Expand Down Expand Up @@ -502,12 +502,12 @@ extension S3 {
guard abortOnFail else {
// if error is MultipartUploadError then we have completed uploading some parts and should include that in the error
if let error = error as? MultipartUploadError {
throw S3ErrorType.multipart.abortedUpload(
throw S3ErrorType.MultipartError.abortedUpload(
resumeRequest: .init(uploadRequest: input, uploadId: uploadId, completedParts: error.completedParts),
error: error.error
)
} else {
throw S3ErrorType.multipart.abortedUpload(
throw S3ErrorType.MultipartError.abortedUpload(
resumeRequest: .init(uploadRequest: input, uploadId: uploadId, completedParts: []),
error: error
)
Expand Down Expand Up @@ -619,12 +619,12 @@ extension S3 {
guard abortOnFail else {
// if error is MultipartUploadError then we have completed uploading some parts and should include that in the error
if let error = error as? MultipartUploadError {
throw S3ErrorType.multipart.abortedUpload(
throw S3ErrorType.MultipartError.abortedUpload(
resumeRequest: .init(uploadRequest: uploadRequest, uploadId: input.uploadId, completedParts: error.completedParts),
error: error.error
)
} else {
throw S3ErrorType.multipart.abortedUpload(
throw S3ErrorType.MultipartError.abortedUpload(
resumeRequest: .init(uploadRequest: uploadRequest, uploadId: input.uploadId, completedParts: []),
error: error
)
Expand Down
4 changes: 2 additions & 2 deletions Tests/SotoTests/Services/S3/S3ExtensionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ extension S3Tests {
}

XCTFail("First multipartUpload was successful")
} catch S3ErrorType.multipart.abortedUpload(let resumeRequest, _) {
} catch S3ErrorType.MultipartError.abortedUpload(let resumeRequest, _) {
do {
_ = try await s3.resumeMultipartUpload(
resumeRequest,
Expand All @@ -181,7 +181,7 @@ extension S3Tests {
guard $0 < 0.95 else { throw CancelError() }
print("Progress \($0 * 100)")
}
} catch S3ErrorType.multipart.abortedUpload(let resumeRequest, _) {
} catch S3ErrorType.MultipartError.abortedUpload(let resumeRequest, _) {
_ = try await s3.resumeMultipartUpload(
resumeRequest,
partSize: 5 * 1024 * 1024,
Expand Down
Loading