bool FBuildPatchVerificationImpl::VerfiyFileSha(const FString& BuildFile, double& TimeSpentPaused) { FSHAHashData BuildFileHash; bool bFoundHash = Manifest->GetFileHash(BuildFile, BuildFileHash); checkf(bFoundHash, TEXT("Missing file hash from manifest.")) return FBuildPatchUtils::VerifyFile( SelectFullFilePath(BuildFile), BuildFileHash, BuildFileHash, FBuildPatchFloatDelegate::CreateRaw(this, &FBuildPatchVerificationImpl::PerFileProgress), ShouldPauseDelegate, TimeSpentPaused) != 0; }
bool FBuildPatchVerificationImpl::VerfiyFileSize(const FString& BuildFile, double& TimeSpentPaused) { // Pause if necessary const double PrePauseTime = FPlatformTime::Seconds(); double PostPauseTime = PrePauseTime; bool bShouldPause = ShouldPauseDelegate.IsBound() && ShouldPauseDelegate.Execute(); while (bShouldPause && !FBuildPatchInstallError::HasFatalError()) { FPlatformProcess::Sleep(0.1f); bShouldPause = ShouldPauseDelegate.Execute(); PostPauseTime = FPlatformTime::Seconds(); } // Count up pause time TimeSpentPaused += PostPauseTime - PrePauseTime; PerFileProgress(0.0f); int64 FileSize = IFileManager::Get().FileSize(*SelectFullFilePath(BuildFile)); PerFileProgress(1.0f); return FileSize == Manifest->GetFileSize(BuildFile); }
bool FBuildPatchVerificationImpl::VerifyAgainstDirectory(TArray<FString>& OutDatedFiles, double& TimeSpentPaused) { bool bAllCorrect = true; OutDatedFiles.Empty(); TimeSpentPaused = 0; // Setup progress tracking double TotalBuildSizeDouble = Manifest->GetBuildSize(); double ProcessedBytes = 0; CurrentBuildPercentage = 0; // For all files in the manifest, check that they produce the correct SHA1 hash, adding any that don't to the list TArray<FString> BuildFiles; Manifest->GetFileList(BuildFiles); for (const FString& BuildFile : BuildFiles) { // Get file details int64 BuildFileSize = Manifest->GetFileSize(BuildFile); FSHAHashData BuildFileHash; bool bFoundHash = Manifest->GetFileHash(BuildFile, BuildFileHash); check(bFoundHash); // Chose the file to check FString FullFilename = SelectFullFilePath(BuildFile); // Verify the file CurrentFileWeight = BuildFileSize / TotalBuildSizeDouble; if (FBuildPatchUtils::VerifyFile(FullFilename, BuildFileHash, BuildFileHash, FBuildPatchFloatDelegate::CreateRaw(this, &FBuildPatchVerificationImpl::PerFileProgress), ShouldPauseDelegate, TimeSpentPaused) == 0) { bAllCorrect = false; OutDatedFiles.Add(BuildFile); } ProcessedBytes += BuildFileSize; CurrentBuildPercentage = ProcessedBytes / TotalBuildSizeDouble; } return bAllCorrect && !FBuildPatchInstallError::HasFatalError(); }