|
9 | 9 | #include <aws/core/utils/crypto/Hash.h> |
10 | 10 | #include <aws/core/utils/crypto/CRC32.h> |
11 | 11 | #include <aws/core/utils/crypto/CRC64.h> |
| 12 | +#include <aws/core/utils/crypto/Sha1.h> |
| 13 | +#include <aws/core/utils/crypto/Sha256.h> |
12 | 14 | #include <aws/core/utils/memory/AWSMemory.h> |
13 | 15 | #include <aws/core/utils/memory/stl/AWSStreamFwd.h> |
14 | 16 | #include <aws/core/utils/memory/stl/AWSStringStream.h> |
@@ -402,14 +404,24 @@ namespace Aws |
402 | 404 | bool isRetry = !handle->GetMultiPartId().empty(); |
403 | 405 | uint64_t sentBytes = 0; |
404 | 406 |
|
405 | | - std::shared_ptr<Aws::Utils::Crypto::Hash> fullObjectHashCalculator; |
406 | | - if (handle->GetChecksum().empty() && !isRetry) { |
407 | | - if (m_transferConfig.checksumAlgorithm == S3::Model::ChecksumAlgorithm::CRC32C) { |
408 | | - fullObjectHashCalculator = Aws::MakeShared<Aws::Utils::Crypto::CRC32C>("TransferManager"); |
409 | | - } else{ |
410 | | - fullObjectHashCalculator = Aws::MakeShared<Aws::Utils::Crypto::CRC64>("TransferManager"); |
| 407 | + const auto fullObjectHashCalculator = [](const std::shared_ptr<TransferHandle>& handle, bool isRetry, S3::Model::ChecksumAlgorithm algorithm) -> std::shared_ptr<Aws::Utils::Crypto::Hash> { |
| 408 | + if (handle->GetChecksum().empty() && !isRetry) { |
| 409 | + if (algorithm == S3::Model::ChecksumAlgorithm::CRC32) { |
| 410 | + return Aws::MakeShared<Aws::Utils::Crypto::CRC32>("TransferManager"); |
| 411 | + } |
| 412 | + if (algorithm == S3::Model::ChecksumAlgorithm::CRC32C) { |
| 413 | + return Aws::MakeShared<Aws::Utils::Crypto::CRC32C>("TransferManager"); |
| 414 | + } |
| 415 | + if (algorithm == S3::Model::ChecksumAlgorithm::SHA1) { |
| 416 | + return Aws::MakeShared<Aws::Utils::Crypto::Sha1>("TransferManager"); |
| 417 | + } |
| 418 | + if (algorithm == S3::Model::ChecksumAlgorithm::SHA256) { |
| 419 | + return Aws::MakeShared<Aws::Utils::Crypto::Sha256>("TransferManager"); |
| 420 | + } |
| 421 | + return Aws::MakeShared<Aws::Utils::Crypto::CRC64>("TransferManager"); |
411 | 422 | } |
412 | | - } |
| 423 | + return nullptr; |
| 424 | + }(handle, isRetry, m_transferConfig.checksumAlgorithm); |
413 | 425 |
|
414 | 426 | if (!isRetry) { |
415 | 427 | Aws::S3::Model::CreateMultipartUploadRequest createMultipartRequest = m_transferConfig.createMultipartUploadTemplate; |
|
0 commit comments