@@ -1006,7 +1006,6 @@ namespace Aws
10061006
10071007 // Store full object checksum from HeadObject for validation
10081008 const auto & headResult = headObjectOutcome.GetResult ();
1009- // Capture any available checksum for validation (prioritize CRC32 as per SEP)
10101009 if (!headResult.GetChecksumCRC32 ().empty ()) {
10111010 handle->SetChecksum (headResult.GetChecksumCRC32 ());
10121011 } else if (!headResult.GetChecksumCRC32C ().empty ()) {
@@ -1250,11 +1249,9 @@ namespace Aws
12501249 if (failedParts.size () == 0 && handle->GetBytesTransferred () == handle->GetBytesTotalSize ())
12511250 {
12521251 outcome.GetResult ().GetBody ().flush ();
1253-
1254- // Validate full object checksum if available
1252+
12551253 bool checksumValid = true ;
12561254 if (!handle->GetChecksum ().empty ()) {
1257- // Combine part checksums to calculate full object checksum
12581255 Aws::String calculatedChecksum = CombinePartChecksums (handle);
12591256
12601257 if (!calculatedChecksum.empty () && calculatedChecksum != handle->GetChecksum ()) {
@@ -1274,11 +1271,9 @@ namespace Aws
12741271 return ;
12751272 }
12761273 }
1277-
1278- // Rename temp file to final file if using temporary file pattern
1274+
12791275 if (!handle->GetTargetFilePath ().empty () && checksumValid) {
12801276 if (handle->GetTargetFilePath ().find (" .s3tmp." ) != Aws::String::npos) {
1281- // This is a temp file, rename to final
12821277 Aws::String finalFile = handle->GetTargetFilePath ();
12831278 size_t pos = finalFile.find (" .s3tmp." );
12841279 if (pos != Aws::String::npos) {
@@ -1675,8 +1670,7 @@ namespace Aws
16751670 sortedParts.emplace_back (part.first , part.second ->GetChecksum ());
16761671 }
16771672 std::sort (sortedParts.begin (), sortedParts.end ());
1678-
1679- // For CRC32, combine checksums using XOR (simplified approach)
1673+
16801674 uint32_t combinedCrc = 0 ;
16811675 for (const auto & part : sortedParts) {
16821676 char * endPtr = nullptr ;
@@ -1688,34 +1682,29 @@ namespace Aws
16881682 }
16891683 combinedCrc ^= partCrc;
16901684 }
1691-
1692- // Convert back to hex string
1685+
16931686 std::stringstream ss;
16941687 ss << std::hex << combinedCrc;
16951688 return ss.str ();
16961689 }
16971690
16981691 Aws::String TransferManager::GenerateTempFileName (const Aws::String& finalFileName) {
1699- // Generate unique identifier (max 8 chars as per SEP)
17001692 Aws::String uuid = Aws::Utils::UUID::RandomUUID ();
17011693 Aws::String uniqueId = uuid.length () > 8 ? uuid.substr (0 , 8 ) : uuid;
17021694 return finalFileName + " .s3tmp." + uniqueId;
17031695 }
17041696
17051697 bool TransferManager::RenameTempFileToFinal (const Aws::String& tempFile, const Aws::String& finalFile) {
1706- // Use atomic rename if supported by platform
17071698 if (std::rename (tempFile.c_str (), finalFile.c_str ()) == 0 ) {
17081699 return true ;
17091700 }
1710-
1711- // Fallback strategy for platforms without atomic rename
1701+
17121702 if (Aws::FileSystem::RemoveFileIfExists (finalFile.c_str ())) {
17131703 if (std::rename (tempFile.c_str (), finalFile.c_str ()) == 0 ) {
17141704 return true ;
17151705 }
17161706 }
1717-
1718- // Clean up temp file on failure
1707+
17191708 Aws::FileSystem::RemoveFileIfExists (tempFile.c_str ());
17201709 return false ;
17211710 }
0 commit comments