File tree Expand file tree Collapse file tree 3 files changed +15
-19
lines changed
Expand file tree Collapse file tree 3 files changed +15
-19
lines changed Original file line number Diff line number Diff line change @@ -373,6 +373,7 @@ namespace Aws
373373 * Return empty string on success, string with error message on error.
374374 */
375375 Aws::String WritePartToDownloadStream (Aws::IOStream* partStream, uint64_t writeOffset);
376+ void AddChecksumForPart (Aws::IOStream* partStream, const PartPointer& shared);
376377
377378 void ApplyDownloadConfiguration (const DownloadConfiguration& downloadConfig);
378379
Original file line number Diff line number Diff line change 33 * SPDX-License-Identifier: Apache-2.0.
44 */
55
6- #include < aws/transfer/TransferHandle.h>
76#include < aws/core/utils/logging/LogMacros.h>
87#include < aws/core/utils/memory/stl/SimpleStringStream.h>
8+ #include < aws/transfer/TransferHandle.h>
99
1010#include < cassert>
1111
12+ #include " aws/core/utils/crypto/CRC64.h"
13+
1214namespace Aws
1315{
1416 namespace Transfer
@@ -423,6 +425,16 @@ namespace Aws
423425 return " " ;
424426 }
425427
428+ void TransferHandle::AddChecksumForPart (Aws::IOStream* partStream, const PartPointer& partState) {
429+ partStream->seekg (0 );
430+ if (GetChecksumAlgorithm () == S3::Model::ChecksumAlgorithm::CRC64NVME) {
431+ // TODO: fix this
432+ partState->SetChecksum (Aws::Utils::Crypto::CRC64::Calculate (partStream->rdbuf ()));
433+ }
434+ partStream->clear ();
435+ partStream->seekg (0 );
436+ }
437+
426438 void TransferHandle::ApplyDownloadConfiguration (const DownloadConfiguration& downloadConfig)
427439 {
428440 SetVersionId (downloadConfig.versionId );
Original file line number Diff line number Diff line change @@ -1262,26 +1262,9 @@ namespace Aws
12621262 Aws::IOStream* bufferStream = partState->GetDownloadPartStream ();
12631263 assert (bufferStream);
12641264
1265+ handle->AddChecksumForPart (bufferStream, partState);
12651266 Aws::String errMsg{handle->WritePartToDownloadStream (bufferStream, partState->GetRangeBegin ())};
12661267 if (errMsg.empty ()) {
1267- partState->SetChecksum ([&]() -> Aws::String {
1268- if (!outcome.GetResult ().GetChecksumCRC32 ().empty ()) {
1269- return outcome.GetResult ().GetChecksumCRC32 ();
1270- }
1271- if (!outcome.GetResult ().GetChecksumCRC32C ().empty ()) {
1272- return outcome.GetResult ().GetChecksumCRC32C ();
1273- }
1274- if (!outcome.GetResult ().GetChecksumCRC64NVME ().empty ()) {
1275- return outcome.GetResult ().GetChecksumCRC64NVME ();
1276- }
1277- if (!outcome.GetResult ().GetChecksumSHA1 ().empty ()) {
1278- return outcome.GetResult ().GetChecksumSHA1 ();
1279- }
1280- if (!outcome.GetResult ().GetChecksumSHA256 ().empty ()) {
1281- return outcome.GetResult ().GetChecksumSHA256 ();
1282- }
1283- return " " ;
1284- }());
12851268 handle->ChangePartToCompleted (partState, outcome.GetResult ().GetETag ());
12861269 } else {
12871270 Aws::Client::AWSError<Aws::S3::S3Errors> error (Aws::S3::S3Errors::INTERNAL_FAILURE,
You can’t perform that action at this time.
0 commit comments