You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rb Per.Larsson #jira UE-176605 #preflight 63ea68d9b91ae11c1cbab311 - A common problem that has been reported is that the user has tried to virtualize packages with the virtualization tool but not seen any virtualization occur. When debugged the issue turns out to be that the packages are too old and need to be re-saved. - If the user submits via the editor then the package will be auto reverted if it has not yet been re-saved so this problem is not seen in that flow. - Although this is a problem that will solve itself over time, it would be helpful to the person testing the system if we explicitly log that X number of packages were too old. - Given how annoying this has proven to people the log message is currently set to warning. - We don't actually return why a package trailer fails to load from FPackageTrailer::LoadTrailer, as working that out requires additional file reading and most the time we don't really care. - Instead I added a new utility to the virtualization module so that we can opt into checking the reason. - At the moment we only report if the package is too old and not for every possible reason. [CL 24206813 by paul chipchase in ue5-main branch]
82 lines
2.0 KiB
C++
82 lines
2.0 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "VirtualizationUtilities.h"
|
|
|
|
#include "IO/IoHash.h"
|
|
#include "Misc/StringBuilder.h"
|
|
#include "UObject/PackageFileSummary.h"
|
|
#include "UObject/PackageResourceManager.h"
|
|
|
|
namespace UE::Virtualization::Utils
|
|
{
|
|
|
|
void PayloadIdToPath(const FIoHash& Id, FStringBuilderBase& OutPath)
|
|
{
|
|
OutPath.Reset();
|
|
OutPath << Id;
|
|
|
|
TStringBuilder<10> Directory;
|
|
Directory << OutPath.ToView().Left(2) << TEXT("/");
|
|
Directory << OutPath.ToView().Mid(2, 2) << TEXT("/");
|
|
Directory << OutPath.ToView().Mid(4, 2) << TEXT("/");
|
|
|
|
OutPath.ReplaceAt(0, 6, Directory);
|
|
|
|
OutPath << TEXT(".upayload");
|
|
}
|
|
|
|
FString PayloadIdToPath(const FIoHash& Id)
|
|
{
|
|
TStringBuilder<52> Path;
|
|
PayloadIdToPath(Id, Path);
|
|
|
|
return FString(Path);
|
|
}
|
|
|
|
void GetFormattedSystemError(FStringBuilderBase& SystemErrorMessage)
|
|
{
|
|
SystemErrorMessage.Reset();
|
|
|
|
const uint32 SystemError = FPlatformMisc::GetLastError();
|
|
// If we have a system error we can give a more informative error message but don't output it if the error is zero as
|
|
// this can lead to very confusing error messages.
|
|
if (SystemError != 0)
|
|
{
|
|
TCHAR SystemErrorMsg[MAX_SPRINTF] = { 0 };
|
|
FPlatformMisc::GetSystemErrorMessage(SystemErrorMsg, sizeof(SystemErrorMsg), SystemError);
|
|
|
|
SystemErrorMessage.Appendf(TEXT("'%s' (%d)"), SystemErrorMsg, SystemError);
|
|
}
|
|
else
|
|
{
|
|
SystemErrorMessage << TEXT("'unknown reason' (0)");
|
|
}
|
|
}
|
|
|
|
ETrailerFailedReason FindTrailerFailedReason(const FPackagePath& PackagePath)
|
|
{
|
|
TUniquePtr<FArchive> Ar = IPackageResourceManager::Get().OpenReadExternalResource(EPackageExternalResource::WorkspaceDomainFile, PackagePath.GetPackageName());
|
|
|
|
if (!Ar)
|
|
{
|
|
return ETrailerFailedReason::NotFound;
|
|
}
|
|
|
|
FPackageFileSummary Summary;
|
|
*Ar << Summary;
|
|
|
|
if (Ar->IsError() || Summary.Tag != PACKAGE_FILE_TAG)
|
|
{
|
|
return ETrailerFailedReason::InvalidSummary;
|
|
}
|
|
|
|
if (Summary.GetFileVersionUE() < EUnrealEngineObjectUE5Version::PAYLOAD_TOC)
|
|
{
|
|
return ETrailerFailedReason::OutOfDate;
|
|
}
|
|
|
|
return ETrailerFailedReason::Unknown;
|
|
}
|
|
|
|
} // namespace UE::Virtualization::Utils
|