Add a rehydration command to the stand alone virtualization tool, making it easier to reverse the effects of asset virtualization. Unlike previous processes, this one does not require that we load the package and will just manipulate the data storaged in the package trailer.
#rb Sebastian.Nordgren
#rnx
#jira UE-156436
#preflight 62c287f9a3568e30664eb94f
### VA Standalone Tool
- We now plan to add much more functionality to the tool than just virtualizing and submitting changelists, so to make this easier I am moving the tool towards a design where it should be fairly easy to add new functionality.
- Added FCommand, which is a base class for adding new functionality, simple derive from FCommand and hook it up at the appropriate locations.
-- In the future it should be possible for new command types to automatically register themselves to be initiated from the command line. There should be no need to edit UnrealVirtualizationToolApp to add a new command but this will be done as an additional work item.
-- At the moment FCommand comes with a number of utility methods to call that cover some common source control commands.
-- The original functionality has not yet been moved to the command system and so the code is a little bit weird at the moment. Updating older code to the new system will be done as an additional work item.
- FProject/FPlugin have been moved to their own code files.
### Rehydrate Command
- The rehydrate command will take a number of packages, check them out of source control and then attempt to virtualize them.
- At the moment the chekout logic is fairly basic, we just check out every package supplied, we don't check if the package is virtualized or not yet. This can be improved in additional work items. Ideally by the end of command the only packages that we have checked out should also be rehydrated.
- At the moment the command can either take a path of a specific package, a path of a directory to find packages in, or a changelist containing packages that should be rehydrated.
- A cleint spec (workspace) can optionally be provided, but if not supplied we will attempt to find a client spec for which to check out the packages.
- Currently we will check out the packages to the default change list.
### Rehydrate process
- Added the rehydration process in it's own code files in the virtualization module. Like the virtualization process this is exposed in a public header file and no via the Core interface which means it is very specific to our module/implementation.
- The process expects that the caller will have checked out any required packages from source control. It will treat being unable to update a package file as an error.
- Added PackageUtils.h/.cpp and moved some of the generic code from the virtualization process code there so that it can be shared by the rehydration process.
### Misc
Moving away from the using things like FPackagePath as that requires that the correct mount points have been registered for a project and at the moment (with the flakiness of FConfig*) it seems that the best idea would be to prefer absolute file paths where possible.
[CL 20982284 by paul chipchase in ue5-main branch]
2022-07-07 06:54:33 -04:00
// Copyright Epic Games, Inc. All Rights Reserved.
# include "PackageRehydrationProcess.h"
# include "HAL/FileManager.h"
# include "Internationalization/Internationalization.h"
# include "Misc/PackageName.h"
# include "Misc/PackagePath.h"
2022-07-15 06:38:07 -04:00
# include "Misc/ScopedSlowTask.h"
Add a rehydration command to the stand alone virtualization tool, making it easier to reverse the effects of asset virtualization. Unlike previous processes, this one does not require that we load the package and will just manipulate the data storaged in the package trailer.
#rb Sebastian.Nordgren
#rnx
#jira UE-156436
#preflight 62c287f9a3568e30664eb94f
### VA Standalone Tool
- We now plan to add much more functionality to the tool than just virtualizing and submitting changelists, so to make this easier I am moving the tool towards a design where it should be fairly easy to add new functionality.
- Added FCommand, which is a base class for adding new functionality, simple derive from FCommand and hook it up at the appropriate locations.
-- In the future it should be possible for new command types to automatically register themselves to be initiated from the command line. There should be no need to edit UnrealVirtualizationToolApp to add a new command but this will be done as an additional work item.
-- At the moment FCommand comes with a number of utility methods to call that cover some common source control commands.
-- The original functionality has not yet been moved to the command system and so the code is a little bit weird at the moment. Updating older code to the new system will be done as an additional work item.
- FProject/FPlugin have been moved to their own code files.
### Rehydrate Command
- The rehydrate command will take a number of packages, check them out of source control and then attempt to virtualize them.
- At the moment the chekout logic is fairly basic, we just check out every package supplied, we don't check if the package is virtualized or not yet. This can be improved in additional work items. Ideally by the end of command the only packages that we have checked out should also be rehydrated.
- At the moment the command can either take a path of a specific package, a path of a directory to find packages in, or a changelist containing packages that should be rehydrated.
- A cleint spec (workspace) can optionally be provided, but if not supplied we will attempt to find a client spec for which to check out the packages.
- Currently we will check out the packages to the default change list.
### Rehydrate process
- Added the rehydration process in it's own code files in the virtualization module. Like the virtualization process this is exposed in a public header file and no via the Core interface which means it is very specific to our module/implementation.
- The process expects that the caller will have checked out any required packages from source control. It will treat being unable to update a package file as an error.
- Added PackageUtils.h/.cpp and moved some of the generic code from the virtualization process code there so that it can be shared by the rehydration process.
### Misc
Moving away from the using things like FPackagePath as that requires that the correct mount points have been registered for a project and at the moment (with the flakiness of FConfig*) it seems that the best idea would be to prefer absolute file paths where possible.
[CL 20982284 by paul chipchase in ue5-main branch]
2022-07-07 06:54:33 -04:00
# include "PackageUtils.h"
2022-10-13 16:28:28 -04:00
# include "Serialization/MemoryArchive.h"
Add a rehydration command to the stand alone virtualization tool, making it easier to reverse the effects of asset virtualization. Unlike previous processes, this one does not require that we load the package and will just manipulate the data storaged in the package trailer.
#rb Sebastian.Nordgren
#rnx
#jira UE-156436
#preflight 62c287f9a3568e30664eb94f
### VA Standalone Tool
- We now plan to add much more functionality to the tool than just virtualizing and submitting changelists, so to make this easier I am moving the tool towards a design where it should be fairly easy to add new functionality.
- Added FCommand, which is a base class for adding new functionality, simple derive from FCommand and hook it up at the appropriate locations.
-- In the future it should be possible for new command types to automatically register themselves to be initiated from the command line. There should be no need to edit UnrealVirtualizationToolApp to add a new command but this will be done as an additional work item.
-- At the moment FCommand comes with a number of utility methods to call that cover some common source control commands.
-- The original functionality has not yet been moved to the command system and so the code is a little bit weird at the moment. Updating older code to the new system will be done as an additional work item.
- FProject/FPlugin have been moved to their own code files.
### Rehydrate Command
- The rehydrate command will take a number of packages, check them out of source control and then attempt to virtualize them.
- At the moment the chekout logic is fairly basic, we just check out every package supplied, we don't check if the package is virtualized or not yet. This can be improved in additional work items. Ideally by the end of command the only packages that we have checked out should also be rehydrated.
- At the moment the command can either take a path of a specific package, a path of a directory to find packages in, or a changelist containing packages that should be rehydrated.
- A cleint spec (workspace) can optionally be provided, but if not supplied we will attempt to find a client spec for which to check out the packages.
- Currently we will check out the packages to the default change list.
### Rehydrate process
- Added the rehydration process in it's own code files in the virtualization module. Like the virtualization process this is exposed in a public header file and no via the Core interface which means it is very specific to our module/implementation.
- The process expects that the caller will have checked out any required packages from source control. It will treat being unable to update a package file as an error.
- Added PackageUtils.h/.cpp and moved some of the generic code from the virtualization process code there so that it can be shared by the rehydration process.
### Misc
Moving away from the using things like FPackagePath as that requires that the correct mount points have been registered for a project and at the moment (with the flakiness of FConfig*) it seems that the best idea would be to prefer absolute file paths where possible.
[CL 20982284 by paul chipchase in ue5-main branch]
2022-07-07 06:54:33 -04:00
# include "UObject/Linker.h"
2022-07-15 06:38:07 -04:00
# include "UObject/Package.h"
Add a rehydration command to the stand alone virtualization tool, making it easier to reverse the effects of asset virtualization. Unlike previous processes, this one does not require that we load the package and will just manipulate the data storaged in the package trailer.
#rb Sebastian.Nordgren
#rnx
#jira UE-156436
#preflight 62c287f9a3568e30664eb94f
### VA Standalone Tool
- We now plan to add much more functionality to the tool than just virtualizing and submitting changelists, so to make this easier I am moving the tool towards a design where it should be fairly easy to add new functionality.
- Added FCommand, which is a base class for adding new functionality, simple derive from FCommand and hook it up at the appropriate locations.
-- In the future it should be possible for new command types to automatically register themselves to be initiated from the command line. There should be no need to edit UnrealVirtualizationToolApp to add a new command but this will be done as an additional work item.
-- At the moment FCommand comes with a number of utility methods to call that cover some common source control commands.
-- The original functionality has not yet been moved to the command system and so the code is a little bit weird at the moment. Updating older code to the new system will be done as an additional work item.
- FProject/FPlugin have been moved to their own code files.
### Rehydrate Command
- The rehydrate command will take a number of packages, check them out of source control and then attempt to virtualize them.
- At the moment the chekout logic is fairly basic, we just check out every package supplied, we don't check if the package is virtualized or not yet. This can be improved in additional work items. Ideally by the end of command the only packages that we have checked out should also be rehydrated.
- At the moment the command can either take a path of a specific package, a path of a directory to find packages in, or a changelist containing packages that should be rehydrated.
- A cleint spec (workspace) can optionally be provided, but if not supplied we will attempt to find a client spec for which to check out the packages.
- Currently we will check out the packages to the default change list.
### Rehydrate process
- Added the rehydration process in it's own code files in the virtualization module. Like the virtualization process this is exposed in a public header file and no via the Core interface which means it is very specific to our module/implementation.
- The process expects that the caller will have checked out any required packages from source control. It will treat being unable to update a package file as an error.
- Added PackageUtils.h/.cpp and moved some of the generic code from the virtualization process code there so that it can be shared by the rehydration process.
### Misc
Moving away from the using things like FPackagePath as that requires that the correct mount points have been registered for a project and at the moment (with the flakiness of FConfig*) it seems that the best idea would be to prefer absolute file paths where possible.
[CL 20982284 by paul chipchase in ue5-main branch]
2022-07-07 06:54:33 -04:00
# include "UObject/PackageTrailer.h"
# include "UObject/UObjectGlobals.h"
# include "Virtualization/VirtualizationSystem.h"
2023-01-10 06:27:20 -05:00
# include "VirtualizationSourceControlUtilities.h"
Add a rehydration command to the stand alone virtualization tool, making it easier to reverse the effects of asset virtualization. Unlike previous processes, this one does not require that we load the package and will just manipulate the data storaged in the package trailer.
#rb Sebastian.Nordgren
#rnx
#jira UE-156436
#preflight 62c287f9a3568e30664eb94f
### VA Standalone Tool
- We now plan to add much more functionality to the tool than just virtualizing and submitting changelists, so to make this easier I am moving the tool towards a design where it should be fairly easy to add new functionality.
- Added FCommand, which is a base class for adding new functionality, simple derive from FCommand and hook it up at the appropriate locations.
-- In the future it should be possible for new command types to automatically register themselves to be initiated from the command line. There should be no need to edit UnrealVirtualizationToolApp to add a new command but this will be done as an additional work item.
-- At the moment FCommand comes with a number of utility methods to call that cover some common source control commands.
-- The original functionality has not yet been moved to the command system and so the code is a little bit weird at the moment. Updating older code to the new system will be done as an additional work item.
- FProject/FPlugin have been moved to their own code files.
### Rehydrate Command
- The rehydrate command will take a number of packages, check them out of source control and then attempt to virtualize them.
- At the moment the chekout logic is fairly basic, we just check out every package supplied, we don't check if the package is virtualized or not yet. This can be improved in additional work items. Ideally by the end of command the only packages that we have checked out should also be rehydrated.
- At the moment the command can either take a path of a specific package, a path of a directory to find packages in, or a changelist containing packages that should be rehydrated.
- A cleint spec (workspace) can optionally be provided, but if not supplied we will attempt to find a client spec for which to check out the packages.
- Currently we will check out the packages to the default change list.
### Rehydrate process
- Added the rehydration process in it's own code files in the virtualization module. Like the virtualization process this is exposed in a public header file and no via the Core interface which means it is very specific to our module/implementation.
- The process expects that the caller will have checked out any required packages from source control. It will treat being unable to update a package file as an error.
- Added PackageUtils.h/.cpp and moved some of the generic code from the virtualization process code there so that it can be shared by the rehydration process.
### Misc
Moving away from the using things like FPackagePath as that requires that the correct mount points have been registered for a project and at the moment (with the flakiness of FConfig*) it seems that the best idea would be to prefer absolute file paths where possible.
[CL 20982284 by paul chipchase in ue5-main branch]
2022-07-07 06:54:33 -04:00
# define LOCTEXT_NAMESPACE "Virtualization"
namespace UE : : Virtualization
{
2022-10-13 16:28:28 -04:00
/**
* Archive allowing serialization to a fixed sized memory buffer . Exceeding the
* length of the buffer will cause the archive to log a warning and set its
* error state to true .
*/
class FFixedBufferWriterArchive : public FMemoryArchive
Add a rehydration command to the stand alone virtualization tool, making it easier to reverse the effects of asset virtualization. Unlike previous processes, this one does not require that we load the package and will just manipulate the data storaged in the package trailer.
#rb Sebastian.Nordgren
#rnx
#jira UE-156436
#preflight 62c287f9a3568e30664eb94f
### VA Standalone Tool
- We now plan to add much more functionality to the tool than just virtualizing and submitting changelists, so to make this easier I am moving the tool towards a design where it should be fairly easy to add new functionality.
- Added FCommand, which is a base class for adding new functionality, simple derive from FCommand and hook it up at the appropriate locations.
-- In the future it should be possible for new command types to automatically register themselves to be initiated from the command line. There should be no need to edit UnrealVirtualizationToolApp to add a new command but this will be done as an additional work item.
-- At the moment FCommand comes with a number of utility methods to call that cover some common source control commands.
-- The original functionality has not yet been moved to the command system and so the code is a little bit weird at the moment. Updating older code to the new system will be done as an additional work item.
- FProject/FPlugin have been moved to their own code files.
### Rehydrate Command
- The rehydrate command will take a number of packages, check them out of source control and then attempt to virtualize them.
- At the moment the chekout logic is fairly basic, we just check out every package supplied, we don't check if the package is virtualized or not yet. This can be improved in additional work items. Ideally by the end of command the only packages that we have checked out should also be rehydrated.
- At the moment the command can either take a path of a specific package, a path of a directory to find packages in, or a changelist containing packages that should be rehydrated.
- A cleint spec (workspace) can optionally be provided, but if not supplied we will attempt to find a client spec for which to check out the packages.
- Currently we will check out the packages to the default change list.
### Rehydrate process
- Added the rehydration process in it's own code files in the virtualization module. Like the virtualization process this is exposed in a public header file and no via the Core interface which means it is very specific to our module/implementation.
- The process expects that the caller will have checked out any required packages from source control. It will treat being unable to update a package file as an error.
- Added PackageUtils.h/.cpp and moved some of the generic code from the virtualization process code there so that it can be shared by the rehydration process.
### Misc
Moving away from the using things like FPackagePath as that requires that the correct mount points have been registered for a project and at the moment (with the flakiness of FConfig*) it seems that the best idea would be to prefer absolute file paths where possible.
[CL 20982284 by paul chipchase in ue5-main branch]
2022-07-07 06:54:33 -04:00
{
2022-10-13 16:28:28 -04:00
public :
FFixedBufferWriterArchive ( ) = delete ;
/**
* @ param InBuffer Pointer to the buffer to write to
* @ param InLength Total length ( in bytes ) that can be written to the buffer
*/
FFixedBufferWriterArchive ( uint8 * InBuffer , int64 InLength )
: Buffer ( InBuffer )
, Length ( InLength )
{
SetIsSaving ( true ) ;
}
virtual ~ FFixedBufferWriterArchive ( ) = default ;
/** Returns how much space remains in the internal buffer. */
int64 GetRemainingSpace ( ) const
{
return Length - Offset ;
}
private :
virtual void Serialize ( void * Data , int64 Num ) override
{
if ( Offset + Num < = Length )
{
FMemory : : Memcpy ( & Buffer [ Offset ] , Data , Num ) ;
Offset + = Num ;
}
else
{
UE_LOG ( LogSerialization , Error , TEXT ( " Attempting to write %lld bytes to a FFixedBufferWriterArchive with only %lld bytes of space remaining " ) , Num , GetRemainingSpace ( ) ) ;
SetError ( ) ;
}
}
uint8 * Buffer = nullptr ;
int64 Length = INDEX_NONE ;
} ;
/** Utility for opening a package for reading, including localized error handling */
TUniquePtr < FArchive > OpenFileForReading ( const FString & FilePath , TArray < FText > & OutErrors )
{
TUniquePtr < FArchive > FileHandle ( IFileManager : : Get ( ) . CreateFileReader ( * FilePath ) ) ;
if ( ! FileHandle )
{
FText Message = FText : : Format ( LOCTEXT ( " VAHydration_OpenFailed " , " Unable to open the file '{0}' for reading " ) ,
FText : : FromString ( FilePath ) ) ;
OutErrors . Add ( MoveTemp ( Message ) ) ;
}
return FileHandle ;
}
/** Utility for serializing data from a package, including localized error handling */
bool ReadData ( TUniquePtr < FArchive > & Ar , void * DstBuffer , int64 BytesToRead , const FString & FilePath , TArray < FText > & OutErrors )
{
check ( Ar . IsValid ( ) ) ;
Ar - > Serialize ( DstBuffer , BytesToRead ) ;
if ( ! Ar - > IsError ( ) )
{
return true ;
}
else
{
FText Message = FText : : Format ( LOCTEXT ( " VAHydration_ReadFailed " , " Failed to read {0} bytes from file {1} " ) ,
BytesToRead ,
FText : : FromString ( FilePath ) ) ;
OutErrors . Add ( MoveTemp ( Message ) ) ;
return false ;
}
}
/** Shared rehydration code */
bool TryRehydrateBuilder ( const FString & FilePath , FPackageTrailer & OutTrailer , FPackageTrailerBuilder & OutBuilder , TArray < FText > & OutErrors )
{
if ( ! FPackageName : : IsPackageFilename ( FilePath ) )
{
return false ; // Only rehydrate valid packages
}
if ( ! FPackageTrailer : : TryLoadFromFile ( FilePath , OutTrailer ) )
{
return false ; // Only rehydrate packages with package trailers
}
TArray < FIoHash > VirtualizedPayloads = OutTrailer . GetPayloads ( EPayloadStorageType : : Virtualized ) ;
if ( VirtualizedPayloads . IsEmpty ( ) )
{
return false ; // If the package has no virtualized payloads then we can skip the rest
}
{
TUniquePtr < FArchive > FileAr = OpenFileForReading ( FilePath , OutErrors ) ;
if ( ! FileAr )
{
return false ;
}
OutBuilder = FPackageTrailerBuilder : : CreateFromTrailer ( OutTrailer , * FileAr , FilePath ) ;
}
int32 PayloadsHydrated = 0 ;
IVirtualizationSystem & System = IVirtualizationSystem : : Get ( ) ;
2023-05-16 11:08:09 -04:00
TArray < FPullRequest > Requests ;
Requests . Reserve ( VirtualizedPayloads . Num ( ) ) ;
2022-10-13 16:28:28 -04:00
for ( const FIoHash & Id : VirtualizedPayloads )
{
2023-05-16 11:08:09 -04:00
Requests . Emplace ( FPullRequest ( Id ) ) ;
}
2022-10-13 16:28:28 -04:00
2023-05-16 11:08:09 -04:00
if ( ! System . PullData ( Requests ) )
{
FText Message = FText : : Format ( LOCTEXT ( " VAHydration_PullFailed " , " Unable to pull the data for the package '{0}' " ) ,
FText : : FromString ( FilePath ) ) ;
OutErrors . Add ( Message ) ;
return false ;
}
for ( const FPullRequest & Request : Requests )
{
if ( OutBuilder . UpdatePayloadAsLocal ( Request . GetIdentifier ( ) , Request . GetPayload ( ) ) )
{
PayloadsHydrated + + ;
2022-10-13 16:28:28 -04:00
}
else
{
2023-05-16 11:08:09 -04:00
FText Message = FText : : Format ( LOCTEXT ( " VAHydration_UpdateStatusFailed " , " Unable to update the status for the payload '{0}' in the package '{1}' " ) ,
FText : : FromString ( LexToString ( Request . GetIdentifier ( ) ) ) ,
2022-10-13 16:28:28 -04:00
FText : : FromString ( FilePath ) ) ;
OutErrors . Add ( Message ) ;
return false ;
}
}
2023-05-16 11:08:09 -04:00
check ( OutBuilder . GetNumVirtualizedPayloads ( ) = = 0 ) ;
2022-10-13 16:28:28 -04:00
return PayloadsHydrated > 0 ;
}
2023-01-10 06:27:20 -05:00
void RehydratePackages ( TConstArrayView < FString > PackagePaths , ERehydrationOptions Options , FRehydrationResult & OutResult )
2022-10-13 16:28:28 -04:00
{
TRACE_CPUPROFILER_EVENT_SCOPE ( UE : : Virtualization : : RehydratePackagesOnDisk ) ;
Add a rehydration command to the stand alone virtualization tool, making it easier to reverse the effects of asset virtualization. Unlike previous processes, this one does not require that we load the package and will just manipulate the data storaged in the package trailer.
#rb Sebastian.Nordgren
#rnx
#jira UE-156436
#preflight 62c287f9a3568e30664eb94f
### VA Standalone Tool
- We now plan to add much more functionality to the tool than just virtualizing and submitting changelists, so to make this easier I am moving the tool towards a design where it should be fairly easy to add new functionality.
- Added FCommand, which is a base class for adding new functionality, simple derive from FCommand and hook it up at the appropriate locations.
-- In the future it should be possible for new command types to automatically register themselves to be initiated from the command line. There should be no need to edit UnrealVirtualizationToolApp to add a new command but this will be done as an additional work item.
-- At the moment FCommand comes with a number of utility methods to call that cover some common source control commands.
-- The original functionality has not yet been moved to the command system and so the code is a little bit weird at the moment. Updating older code to the new system will be done as an additional work item.
- FProject/FPlugin have been moved to their own code files.
### Rehydrate Command
- The rehydrate command will take a number of packages, check them out of source control and then attempt to virtualize them.
- At the moment the chekout logic is fairly basic, we just check out every package supplied, we don't check if the package is virtualized or not yet. This can be improved in additional work items. Ideally by the end of command the only packages that we have checked out should also be rehydrated.
- At the moment the command can either take a path of a specific package, a path of a directory to find packages in, or a changelist containing packages that should be rehydrated.
- A cleint spec (workspace) can optionally be provided, but if not supplied we will attempt to find a client spec for which to check out the packages.
- Currently we will check out the packages to the default change list.
### Rehydrate process
- Added the rehydration process in it's own code files in the virtualization module. Like the virtualization process this is exposed in a public header file and no via the Core interface which means it is very specific to our module/implementation.
- The process expects that the caller will have checked out any required packages from source control. It will treat being unable to update a package file as an error.
- Added PackageUtils.h/.cpp and moved some of the generic code from the virtualization process code there so that it can be shared by the rehydration process.
### Misc
Moving away from the using things like FPackagePath as that requires that the correct mount points have been registered for a project and at the moment (with the flakiness of FConfig*) it seems that the best idea would be to prefer absolute file paths where possible.
[CL 20982284 by paul chipchase in ue5-main branch]
2022-07-07 06:54:33 -04:00
IVirtualizationSystem & System = IVirtualizationSystem : : Get ( ) ;
if ( ! System . IsEnabled ( ) )
{
return ;
}
2023-01-10 06:27:20 -05:00
const double StartTime = FPlatformTime : : Seconds ( ) ;
2022-10-13 16:28:28 -04:00
FScopedSlowTask Progress ( 1.0f , LOCTEXT ( " VAHydration_TaskOnDisk " , " Re-hydrating Assets On Disk... " ) ) ;
2022-07-15 06:38:07 -04:00
Progress . MakeDialog ( ) ;
2023-01-10 06:27:20 -05:00
TArray < TPair < FString , FString > > PackagesToReplace ;
// TODO: Should we consider a way to batch this so many payloads can be downloaded at once?
// Running this over a large project would be much faster if we could batch. An easy way
// to do this might be to gather all of the payloads needed and do a prefetch first?
2023-02-16 10:07:47 -05:00
double Time = FPlatformTime : : Seconds ( ) ;
2023-04-20 11:05:45 -04:00
TSet < FString > ConsideredPackages ;
ConsideredPackages . Reserve ( PackagePaths . Num ( ) ) ;
2023-01-10 06:27:20 -05:00
// Attempt to rehydrate the packages
2023-02-16 10:07:47 -05:00
for ( int32 Index = 0 ; Index < PackagePaths . Num ( ) ; + + Index )
Add a rehydration command to the stand alone virtualization tool, making it easier to reverse the effects of asset virtualization. Unlike previous processes, this one does not require that we load the package and will just manipulate the data storaged in the package trailer.
#rb Sebastian.Nordgren
#rnx
#jira UE-156436
#preflight 62c287f9a3568e30664eb94f
### VA Standalone Tool
- We now plan to add much more functionality to the tool than just virtualizing and submitting changelists, so to make this easier I am moving the tool towards a design where it should be fairly easy to add new functionality.
- Added FCommand, which is a base class for adding new functionality, simple derive from FCommand and hook it up at the appropriate locations.
-- In the future it should be possible for new command types to automatically register themselves to be initiated from the command line. There should be no need to edit UnrealVirtualizationToolApp to add a new command but this will be done as an additional work item.
-- At the moment FCommand comes with a number of utility methods to call that cover some common source control commands.
-- The original functionality has not yet been moved to the command system and so the code is a little bit weird at the moment. Updating older code to the new system will be done as an additional work item.
- FProject/FPlugin have been moved to their own code files.
### Rehydrate Command
- The rehydrate command will take a number of packages, check them out of source control and then attempt to virtualize them.
- At the moment the chekout logic is fairly basic, we just check out every package supplied, we don't check if the package is virtualized or not yet. This can be improved in additional work items. Ideally by the end of command the only packages that we have checked out should also be rehydrated.
- At the moment the command can either take a path of a specific package, a path of a directory to find packages in, or a changelist containing packages that should be rehydrated.
- A cleint spec (workspace) can optionally be provided, but if not supplied we will attempt to find a client spec for which to check out the packages.
- Currently we will check out the packages to the default change list.
### Rehydrate process
- Added the rehydration process in it's own code files in the virtualization module. Like the virtualization process this is exposed in a public header file and no via the Core interface which means it is very specific to our module/implementation.
- The process expects that the caller will have checked out any required packages from source control. It will treat being unable to update a package file as an error.
- Added PackageUtils.h/.cpp and moved some of the generic code from the virtualization process code there so that it can be shared by the rehydration process.
### Misc
Moving away from the using things like FPackagePath as that requires that the correct mount points have been registered for a project and at the moment (with the flakiness of FConfig*) it seems that the best idea would be to prefer absolute file paths where possible.
[CL 20982284 by paul chipchase in ue5-main branch]
2022-07-07 06:54:33 -04:00
{
2023-02-16 10:07:47 -05:00
const FString & FilePath = PackagePaths [ Index ] ;
2023-04-20 11:05:45 -04:00
bool bIsDuplicate = false ;
ConsideredPackages . Add ( FilePath , & bIsDuplicate ) ;
if ( bIsDuplicate )
{
UE_LOG ( LogVirtualization , Verbose , TEXT ( " Skipping duplicate package entry '%s' " ) , * FilePath ) ;
continue ; // Skip duplicate packages
}
Add a rehydration command to the stand alone virtualization tool, making it easier to reverse the effects of asset virtualization. Unlike previous processes, this one does not require that we load the package and will just manipulate the data storaged in the package trailer.
#rb Sebastian.Nordgren
#rnx
#jira UE-156436
#preflight 62c287f9a3568e30664eb94f
### VA Standalone Tool
- We now plan to add much more functionality to the tool than just virtualizing and submitting changelists, so to make this easier I am moving the tool towards a design where it should be fairly easy to add new functionality.
- Added FCommand, which is a base class for adding new functionality, simple derive from FCommand and hook it up at the appropriate locations.
-- In the future it should be possible for new command types to automatically register themselves to be initiated from the command line. There should be no need to edit UnrealVirtualizationToolApp to add a new command but this will be done as an additional work item.
-- At the moment FCommand comes with a number of utility methods to call that cover some common source control commands.
-- The original functionality has not yet been moved to the command system and so the code is a little bit weird at the moment. Updating older code to the new system will be done as an additional work item.
- FProject/FPlugin have been moved to their own code files.
### Rehydrate Command
- The rehydrate command will take a number of packages, check them out of source control and then attempt to virtualize them.
- At the moment the chekout logic is fairly basic, we just check out every package supplied, we don't check if the package is virtualized or not yet. This can be improved in additional work items. Ideally by the end of command the only packages that we have checked out should also be rehydrated.
- At the moment the command can either take a path of a specific package, a path of a directory to find packages in, or a changelist containing packages that should be rehydrated.
- A cleint spec (workspace) can optionally be provided, but if not supplied we will attempt to find a client spec for which to check out the packages.
- Currently we will check out the packages to the default change list.
### Rehydrate process
- Added the rehydration process in it's own code files in the virtualization module. Like the virtualization process this is exposed in a public header file and no via the Core interface which means it is very specific to our module/implementation.
- The process expects that the caller will have checked out any required packages from source control. It will treat being unable to update a package file as an error.
- Added PackageUtils.h/.cpp and moved some of the generic code from the virtualization process code there so that it can be shared by the rehydration process.
### Misc
Moving away from the using things like FPackagePath as that requires that the correct mount points have been registered for a project and at the moment (with the flakiness of FConfig*) it seems that the best idea would be to prefer absolute file paths where possible.
[CL 20982284 by paul chipchase in ue5-main branch]
2022-07-07 06:54:33 -04:00
FPackageTrailer Trailer ;
2022-10-13 16:28:28 -04:00
FPackageTrailerBuilder Builder ;
Add a rehydration command to the stand alone virtualization tool, making it easier to reverse the effects of asset virtualization. Unlike previous processes, this one does not require that we load the package and will just manipulate the data storaged in the package trailer.
#rb Sebastian.Nordgren
#rnx
#jira UE-156436
#preflight 62c287f9a3568e30664eb94f
### VA Standalone Tool
- We now plan to add much more functionality to the tool than just virtualizing and submitting changelists, so to make this easier I am moving the tool towards a design where it should be fairly easy to add new functionality.
- Added FCommand, which is a base class for adding new functionality, simple derive from FCommand and hook it up at the appropriate locations.
-- In the future it should be possible for new command types to automatically register themselves to be initiated from the command line. There should be no need to edit UnrealVirtualizationToolApp to add a new command but this will be done as an additional work item.
-- At the moment FCommand comes with a number of utility methods to call that cover some common source control commands.
-- The original functionality has not yet been moved to the command system and so the code is a little bit weird at the moment. Updating older code to the new system will be done as an additional work item.
- FProject/FPlugin have been moved to their own code files.
### Rehydrate Command
- The rehydrate command will take a number of packages, check them out of source control and then attempt to virtualize them.
- At the moment the chekout logic is fairly basic, we just check out every package supplied, we don't check if the package is virtualized or not yet. This can be improved in additional work items. Ideally by the end of command the only packages that we have checked out should also be rehydrated.
- At the moment the command can either take a path of a specific package, a path of a directory to find packages in, or a changelist containing packages that should be rehydrated.
- A cleint spec (workspace) can optionally be provided, but if not supplied we will attempt to find a client spec for which to check out the packages.
- Currently we will check out the packages to the default change list.
### Rehydrate process
- Added the rehydration process in it's own code files in the virtualization module. Like the virtualization process this is exposed in a public header file and no via the Core interface which means it is very specific to our module/implementation.
- The process expects that the caller will have checked out any required packages from source control. It will treat being unable to update a package file as an error.
- Added PackageUtils.h/.cpp and moved some of the generic code from the virtualization process code there so that it can be shared by the rehydration process.
### Misc
Moving away from the using things like FPackagePath as that requires that the correct mount points have been registered for a project and at the moment (with the flakiness of FConfig*) it seems that the best idea would be to prefer absolute file paths where possible.
[CL 20982284 by paul chipchase in ue5-main branch]
2022-07-07 06:54:33 -04:00
2023-01-10 06:27:20 -05:00
if ( TryRehydrateBuilder ( FilePath , Trailer , Builder , OutResult . Errors ) )
Add a rehydration command to the stand alone virtualization tool, making it easier to reverse the effects of asset virtualization. Unlike previous processes, this one does not require that we load the package and will just manipulate the data storaged in the package trailer.
#rb Sebastian.Nordgren
#rnx
#jira UE-156436
#preflight 62c287f9a3568e30664eb94f
### VA Standalone Tool
- We now plan to add much more functionality to the tool than just virtualizing and submitting changelists, so to make this easier I am moving the tool towards a design where it should be fairly easy to add new functionality.
- Added FCommand, which is a base class for adding new functionality, simple derive from FCommand and hook it up at the appropriate locations.
-- In the future it should be possible for new command types to automatically register themselves to be initiated from the command line. There should be no need to edit UnrealVirtualizationToolApp to add a new command but this will be done as an additional work item.
-- At the moment FCommand comes with a number of utility methods to call that cover some common source control commands.
-- The original functionality has not yet been moved to the command system and so the code is a little bit weird at the moment. Updating older code to the new system will be done as an additional work item.
- FProject/FPlugin have been moved to their own code files.
### Rehydrate Command
- The rehydrate command will take a number of packages, check them out of source control and then attempt to virtualize them.
- At the moment the chekout logic is fairly basic, we just check out every package supplied, we don't check if the package is virtualized or not yet. This can be improved in additional work items. Ideally by the end of command the only packages that we have checked out should also be rehydrated.
- At the moment the command can either take a path of a specific package, a path of a directory to find packages in, or a changelist containing packages that should be rehydrated.
- A cleint spec (workspace) can optionally be provided, but if not supplied we will attempt to find a client spec for which to check out the packages.
- Currently we will check out the packages to the default change list.
### Rehydrate process
- Added the rehydration process in it's own code files in the virtualization module. Like the virtualization process this is exposed in a public header file and no via the Core interface which means it is very specific to our module/implementation.
- The process expects that the caller will have checked out any required packages from source control. It will treat being unable to update a package file as an error.
- Added PackageUtils.h/.cpp and moved some of the generic code from the virtualization process code there so that it can be shared by the rehydration process.
### Misc
Moving away from the using things like FPackagePath as that requires that the correct mount points have been registered for a project and at the moment (with the flakiness of FConfig*) it seems that the best idea would be to prefer absolute file paths where possible.
[CL 20982284 by paul chipchase in ue5-main branch]
2022-07-07 06:54:33 -04:00
{
2023-01-10 06:27:20 -05:00
FString NewPackagePath = DuplicatePackageWithNewTrailer ( FilePath , Trailer , Builder , OutResult . Errors ) ;
Add a rehydration command to the stand alone virtualization tool, making it easier to reverse the effects of asset virtualization. Unlike previous processes, this one does not require that we load the package and will just manipulate the data storaged in the package trailer.
#rb Sebastian.Nordgren
#rnx
#jira UE-156436
#preflight 62c287f9a3568e30664eb94f
### VA Standalone Tool
- We now plan to add much more functionality to the tool than just virtualizing and submitting changelists, so to make this easier I am moving the tool towards a design where it should be fairly easy to add new functionality.
- Added FCommand, which is a base class for adding new functionality, simple derive from FCommand and hook it up at the appropriate locations.
-- In the future it should be possible for new command types to automatically register themselves to be initiated from the command line. There should be no need to edit UnrealVirtualizationToolApp to add a new command but this will be done as an additional work item.
-- At the moment FCommand comes with a number of utility methods to call that cover some common source control commands.
-- The original functionality has not yet been moved to the command system and so the code is a little bit weird at the moment. Updating older code to the new system will be done as an additional work item.
- FProject/FPlugin have been moved to their own code files.
### Rehydrate Command
- The rehydrate command will take a number of packages, check them out of source control and then attempt to virtualize them.
- At the moment the chekout logic is fairly basic, we just check out every package supplied, we don't check if the package is virtualized or not yet. This can be improved in additional work items. Ideally by the end of command the only packages that we have checked out should also be rehydrated.
- At the moment the command can either take a path of a specific package, a path of a directory to find packages in, or a changelist containing packages that should be rehydrated.
- A cleint spec (workspace) can optionally be provided, but if not supplied we will attempt to find a client spec for which to check out the packages.
- Currently we will check out the packages to the default change list.
### Rehydrate process
- Added the rehydration process in it's own code files in the virtualization module. Like the virtualization process this is exposed in a public header file and no via the Core interface which means it is very specific to our module/implementation.
- The process expects that the caller will have checked out any required packages from source control. It will treat being unable to update a package file as an error.
- Added PackageUtils.h/.cpp and moved some of the generic code from the virtualization process code there so that it can be shared by the rehydration process.
### Misc
Moving away from the using things like FPackagePath as that requires that the correct mount points have been registered for a project and at the moment (with the flakiness of FConfig*) it seems that the best idea would be to prefer absolute file paths where possible.
[CL 20982284 by paul chipchase in ue5-main branch]
2022-07-07 06:54:33 -04:00
2023-01-10 06:27:20 -05:00
if ( ! NewPackagePath . IsEmpty ( ) )
2022-07-15 06:38:07 -04:00
{
2023-01-10 06:27:20 -05:00
PackagesToReplace . Emplace ( FilePath , MoveTemp ( NewPackagePath ) ) ;
Add a rehydration command to the stand alone virtualization tool, making it easier to reverse the effects of asset virtualization. Unlike previous processes, this one does not require that we load the package and will just manipulate the data storaged in the package trailer.
#rb Sebastian.Nordgren
#rnx
#jira UE-156436
#preflight 62c287f9a3568e30664eb94f
### VA Standalone Tool
- We now plan to add much more functionality to the tool than just virtualizing and submitting changelists, so to make this easier I am moving the tool towards a design where it should be fairly easy to add new functionality.
- Added FCommand, which is a base class for adding new functionality, simple derive from FCommand and hook it up at the appropriate locations.
-- In the future it should be possible for new command types to automatically register themselves to be initiated from the command line. There should be no need to edit UnrealVirtualizationToolApp to add a new command but this will be done as an additional work item.
-- At the moment FCommand comes with a number of utility methods to call that cover some common source control commands.
-- The original functionality has not yet been moved to the command system and so the code is a little bit weird at the moment. Updating older code to the new system will be done as an additional work item.
- FProject/FPlugin have been moved to their own code files.
### Rehydrate Command
- The rehydrate command will take a number of packages, check them out of source control and then attempt to virtualize them.
- At the moment the chekout logic is fairly basic, we just check out every package supplied, we don't check if the package is virtualized or not yet. This can be improved in additional work items. Ideally by the end of command the only packages that we have checked out should also be rehydrated.
- At the moment the command can either take a path of a specific package, a path of a directory to find packages in, or a changelist containing packages that should be rehydrated.
- A cleint spec (workspace) can optionally be provided, but if not supplied we will attempt to find a client spec for which to check out the packages.
- Currently we will check out the packages to the default change list.
### Rehydrate process
- Added the rehydration process in it's own code files in the virtualization module. Like the virtualization process this is exposed in a public header file and no via the Core interface which means it is very specific to our module/implementation.
- The process expects that the caller will have checked out any required packages from source control. It will treat being unable to update a package file as an error.
- Added PackageUtils.h/.cpp and moved some of the generic code from the virtualization process code there so that it can be shared by the rehydration process.
### Misc
Moving away from the using things like FPackagePath as that requires that the correct mount points have been registered for a project and at the moment (with the flakiness of FConfig*) it seems that the best idea would be to prefer absolute file paths where possible.
[CL 20982284 by paul chipchase in ue5-main branch]
2022-07-07 06:54:33 -04:00
}
else
{
2023-01-10 06:27:20 -05:00
// Error?
2022-07-15 06:38:07 -04:00
return ;
Add a rehydration command to the stand alone virtualization tool, making it easier to reverse the effects of asset virtualization. Unlike previous processes, this one does not require that we load the package and will just manipulate the data storaged in the package trailer.
#rb Sebastian.Nordgren
#rnx
#jira UE-156436
#preflight 62c287f9a3568e30664eb94f
### VA Standalone Tool
- We now plan to add much more functionality to the tool than just virtualizing and submitting changelists, so to make this easier I am moving the tool towards a design where it should be fairly easy to add new functionality.
- Added FCommand, which is a base class for adding new functionality, simple derive from FCommand and hook it up at the appropriate locations.
-- In the future it should be possible for new command types to automatically register themselves to be initiated from the command line. There should be no need to edit UnrealVirtualizationToolApp to add a new command but this will be done as an additional work item.
-- At the moment FCommand comes with a number of utility methods to call that cover some common source control commands.
-- The original functionality has not yet been moved to the command system and so the code is a little bit weird at the moment. Updating older code to the new system will be done as an additional work item.
- FProject/FPlugin have been moved to their own code files.
### Rehydrate Command
- The rehydrate command will take a number of packages, check them out of source control and then attempt to virtualize them.
- At the moment the chekout logic is fairly basic, we just check out every package supplied, we don't check if the package is virtualized or not yet. This can be improved in additional work items. Ideally by the end of command the only packages that we have checked out should also be rehydrated.
- At the moment the command can either take a path of a specific package, a path of a directory to find packages in, or a changelist containing packages that should be rehydrated.
- A cleint spec (workspace) can optionally be provided, but if not supplied we will attempt to find a client spec for which to check out the packages.
- Currently we will check out the packages to the default change list.
### Rehydrate process
- Added the rehydration process in it's own code files in the virtualization module. Like the virtualization process this is exposed in a public header file and no via the Core interface which means it is very specific to our module/implementation.
- The process expects that the caller will have checked out any required packages from source control. It will treat being unable to update a package file as an error.
- Added PackageUtils.h/.cpp and moved some of the generic code from the virtualization process code there so that it can be shared by the rehydration process.
### Misc
Moving away from the using things like FPackagePath as that requires that the correct mount points have been registered for a project and at the moment (with the flakiness of FConfig*) it seems that the best idea would be to prefer absolute file paths where possible.
[CL 20982284 by paul chipchase in ue5-main branch]
2022-07-07 06:54:33 -04:00
}
}
2023-02-16 10:07:47 -05:00
if ( FPlatformTime : : Seconds ( ) - Time > 10.0 )
{
const float ProgressPercent = ( ( float ) Index / ( float ) PackagePaths . Num ( ) ) * 100.0f ;
UE_LOG ( LogVirtualization , Display , TEXT ( " %d/%d - %.1f%% " ) , Index , PackagePaths . Num ( ) , ProgressPercent ) ;
Time = FPlatformTime : : Seconds ( ) ;
}
Add a rehydration command to the stand alone virtualization tool, making it easier to reverse the effects of asset virtualization. Unlike previous processes, this one does not require that we load the package and will just manipulate the data storaged in the package trailer.
#rb Sebastian.Nordgren
#rnx
#jira UE-156436
#preflight 62c287f9a3568e30664eb94f
### VA Standalone Tool
- We now plan to add much more functionality to the tool than just virtualizing and submitting changelists, so to make this easier I am moving the tool towards a design where it should be fairly easy to add new functionality.
- Added FCommand, which is a base class for adding new functionality, simple derive from FCommand and hook it up at the appropriate locations.
-- In the future it should be possible for new command types to automatically register themselves to be initiated from the command line. There should be no need to edit UnrealVirtualizationToolApp to add a new command but this will be done as an additional work item.
-- At the moment FCommand comes with a number of utility methods to call that cover some common source control commands.
-- The original functionality has not yet been moved to the command system and so the code is a little bit weird at the moment. Updating older code to the new system will be done as an additional work item.
- FProject/FPlugin have been moved to their own code files.
### Rehydrate Command
- The rehydrate command will take a number of packages, check them out of source control and then attempt to virtualize them.
- At the moment the chekout logic is fairly basic, we just check out every package supplied, we don't check if the package is virtualized or not yet. This can be improved in additional work items. Ideally by the end of command the only packages that we have checked out should also be rehydrated.
- At the moment the command can either take a path of a specific package, a path of a directory to find packages in, or a changelist containing packages that should be rehydrated.
- A cleint spec (workspace) can optionally be provided, but if not supplied we will attempt to find a client spec for which to check out the packages.
- Currently we will check out the packages to the default change list.
### Rehydrate process
- Added the rehydration process in it's own code files in the virtualization module. Like the virtualization process this is exposed in a public header file and no via the Core interface which means it is very specific to our module/implementation.
- The process expects that the caller will have checked out any required packages from source control. It will treat being unable to update a package file as an error.
- Added PackageUtils.h/.cpp and moved some of the generic code from the virtualization process code there so that it can be shared by the rehydration process.
### Misc
Moving away from the using things like FPackagePath as that requires that the correct mount points have been registered for a project and at the moment (with the flakiness of FConfig*) it seems that the best idea would be to prefer absolute file paths where possible.
[CL 20982284 by paul chipchase in ue5-main branch]
2022-07-07 06:54:33 -04:00
}
2023-01-10 06:27:20 -05:00
2023-04-20 11:05:45 -04:00
const int32 NumSkippedPackages = PackagePaths . Num ( ) - ConsideredPackages . Num ( ) ;
ConsideredPackages . Empty ( ) ;
UE_CLOG ( NumSkippedPackages > 0 , LogVirtualization , Warning , TEXT ( " Discarded %d duplicate package paths " ) , NumSkippedPackages ) ;
2023-01-10 06:27:20 -05:00
// We need to reset the loader of any loaded package that should have its package file replaced
for ( const TPair < FString , FString > & Pair : PackagesToReplace )
{
const FString & OriginalFilePath = Pair . Key ;
FString PackageName ;
if ( FPackageName : : TryConvertFilenameToLongPackageName ( OriginalFilePath , PackageName ) )
{
UPackage * Package = FindObjectFast < UPackage > ( nullptr , * PackageName ) ;
if ( Package ! = nullptr )
{
UE_LOG ( LogVirtualization , Verbose , TEXT ( " Detaching '%s' from disk so that it can be rehydrated " ) , * OriginalFilePath ) ;
ResetLoadersForSave ( Package , * OriginalFilePath ) ;
}
}
}
// Should we try to check out packages from revision control?
if ( EnumHasAnyFlags ( Options , ERehydrationOptions : : Checkout ) )
{
TArray < FString > FilesToCheckState ;
FilesToCheckState . Reserve ( PackagesToReplace . Num ( ) ) ;
for ( const TPair < FString , FString > & Pair : PackagesToReplace )
{
FilesToCheckState . Add ( Pair . Key ) ;
}
if ( ! TryCheckoutFiles ( FilesToCheckState , OutResult . Errors , & OutResult . CheckedOutPackages ) )
{
return ;
}
}
for ( const TPair < FString , FString > & Pair : PackagesToReplace )
{
const FString & OriginalFilePath = Pair . Key ;
const FString & TempFilePath = Pair . Value ;
if ( CanWriteToFile ( OriginalFilePath ) )
{
if ( IFileManager : : Get ( ) . Move ( * OriginalFilePath , * TempFilePath ) )
{
OutResult . RehydratedPackages . Add ( OriginalFilePath ) ;
}
else
{
FText Message = FText : : Format ( LOCTEXT ( " VAHydration_MoveFailed " , " Unable to replace the package '{0}' with the hydrated version " ) ,
FText : : FromString ( OriginalFilePath ) ) ;
OutResult . AddError ( MoveTemp ( Message ) ) ;
return ;
}
}
else
{
FText Message = FText : : Format (
LOCTEXT ( " VAHydration_PackageLocked " , " The package file '{0}' has virtualized payloads but is locked for modification and cannot be hydrated " ) ,
FText : : FromString ( OriginalFilePath ) ) ;
OutResult . AddError ( MoveTemp ( Message ) ) ;
return ;
}
}
OutResult . TimeTaken = FPlatformTime : : Seconds ( ) - StartTime ;
UE_LOG ( LogVirtualization , Verbose , TEXT ( " Rehydration process took %.3f(s) " ) , OutResult . TimeTaken ) ;
Add a rehydration command to the stand alone virtualization tool, making it easier to reverse the effects of asset virtualization. Unlike previous processes, this one does not require that we load the package and will just manipulate the data storaged in the package trailer.
#rb Sebastian.Nordgren
#rnx
#jira UE-156436
#preflight 62c287f9a3568e30664eb94f
### VA Standalone Tool
- We now plan to add much more functionality to the tool than just virtualizing and submitting changelists, so to make this easier I am moving the tool towards a design where it should be fairly easy to add new functionality.
- Added FCommand, which is a base class for adding new functionality, simple derive from FCommand and hook it up at the appropriate locations.
-- In the future it should be possible for new command types to automatically register themselves to be initiated from the command line. There should be no need to edit UnrealVirtualizationToolApp to add a new command but this will be done as an additional work item.
-- At the moment FCommand comes with a number of utility methods to call that cover some common source control commands.
-- The original functionality has not yet been moved to the command system and so the code is a little bit weird at the moment. Updating older code to the new system will be done as an additional work item.
- FProject/FPlugin have been moved to their own code files.
### Rehydrate Command
- The rehydrate command will take a number of packages, check them out of source control and then attempt to virtualize them.
- At the moment the chekout logic is fairly basic, we just check out every package supplied, we don't check if the package is virtualized or not yet. This can be improved in additional work items. Ideally by the end of command the only packages that we have checked out should also be rehydrated.
- At the moment the command can either take a path of a specific package, a path of a directory to find packages in, or a changelist containing packages that should be rehydrated.
- A cleint spec (workspace) can optionally be provided, but if not supplied we will attempt to find a client spec for which to check out the packages.
- Currently we will check out the packages to the default change list.
### Rehydrate process
- Added the rehydration process in it's own code files in the virtualization module. Like the virtualization process this is exposed in a public header file and no via the Core interface which means it is very specific to our module/implementation.
- The process expects that the caller will have checked out any required packages from source control. It will treat being unable to update a package file as an error.
- Added PackageUtils.h/.cpp and moved some of the generic code from the virtualization process code there so that it can be shared by the rehydration process.
### Misc
Moving away from the using things like FPackagePath as that requires that the correct mount points have been registered for a project and at the moment (with the flakiness of FConfig*) it seems that the best idea would be to prefer absolute file paths where possible.
[CL 20982284 by paul chipchase in ue5-main branch]
2022-07-07 06:54:33 -04:00
}
2022-10-13 16:28:28 -04:00
void RehydratePackages ( TConstArrayView < FString > PackagePaths , uint64 PaddingAlignment , TArray < FText > & OutErrors , TArray < FSharedBuffer > & OutPackages , TArray < FRehydrationInfo > * OutInfo )
{
TRACE_CPUPROFILER_EVENT_SCOPE ( UE : : Virtualization : : RehydratePackagesInMem ) ;
IVirtualizationSystem & System = IVirtualizationSystem : : Get ( ) ;
FScopedSlowTask Progress ( 1.0f , LOCTEXT ( " VAHydration_TaskInMem " , " Re-hydrating Assets In Memory... " ) ) ;
Progress . MakeDialog ( ) ;
OutPackages . Empty ( PackagePaths . Num ( ) ) ;
if ( OutInfo ! = nullptr )
{
OutInfo - > Empty ( PackagePaths . Num ( ) ) ;
}
for ( const FString & FilePath : PackagePaths )
{
FUniqueBuffer FileBuffer ;
FPackageTrailer Trailer ;
FPackageTrailerBuilder Builder ;
if ( System . IsEnabled ( ) & & TryRehydrateBuilder ( FilePath , Trailer , Builder , OutErrors ) )
{
TUniquePtr < FArchive > FileAr = OpenFileForReading ( FilePath , OutErrors ) ;
if ( ! FileAr )
{
return ;
}
const int64 OriginalFileLength = FileAr - > TotalSize ( ) ;
const int64 TruncatedFileLength = OriginalFileLength - Trailer . GetTrailerLength ( ) ;
const int64 RehydratedTrailerLength = ( int64 ) Builder . CalculateTrailerLength ( ) ;
const int64 RehydratedFileLength = TruncatedFileLength + RehydratedTrailerLength ;
const int64 BufferLength = Align ( RehydratedFileLength , PaddingAlignment ) ;
FileBuffer = FUniqueBuffer : : Alloc ( ( uint64 ) BufferLength ) ;
if ( ! ReadData ( FileAr , FileBuffer . GetData ( ) , TruncatedFileLength , FilePath , OutErrors ) )
{
return ;
}
FFixedBufferWriterArchive Ar ( ( uint8 * ) FileBuffer . GetData ( ) + TruncatedFileLength , RehydratedTrailerLength ) ;
if ( ! Builder . BuildAndAppendTrailer ( nullptr , Ar ) )
{
FText Message = FText : : Format ( LOCTEXT ( " VAHydration_TrailerFailed " , " Failed to create a new trailer for file {0} " ) ,
FText : : FromString ( FilePath ) ) ;
OutErrors . Add ( MoveTemp ( Message ) ) ;
return ;
}
check ( Ar . GetRemainingSpace ( ) = = 0 ) ;
if ( OutInfo ! = nullptr )
{
FRehydrationInfo & Info = OutInfo - > AddDefaulted_GetRef ( ) ;
Info . OriginalSize = OriginalFileLength ;
Info . RehydratedSize = RehydratedFileLength ;
Info . NumPayloadsRehydrated = Builder . GetNumLocalPayloads ( ) - Trailer . GetNumPayloads ( EPayloadStorageType : : Local ) ;
}
}
else
{
TUniquePtr < FArchive > FileAr = OpenFileForReading ( FilePath , OutErrors ) ;
if ( ! FileAr )
{
return ;
}
const int64 FileLength = FileAr - > TotalSize ( ) ;
const int64 BufferLength = Align ( FileLength , PaddingAlignment ) ;
FileBuffer = FUniqueBuffer : : Alloc ( ( uint64 ) BufferLength ) ;
if ( ! ReadData ( FileAr , FileBuffer . GetData ( ) , FileLength , FilePath , OutErrors ) )
{
return ;
}
if ( OutInfo ! = nullptr )
{
FRehydrationInfo & Info = OutInfo - > AddDefaulted_GetRef ( ) ;
Info . OriginalSize = FileLength ;
Info . RehydratedSize = FileLength ;
Info . NumPayloadsRehydrated = 0 ;
}
}
OutPackages . Add ( FileBuffer . MoveToShared ( ) ) ;
}
// Make sure the arrays that we return have an entry per requested file
check ( PackagePaths . Num ( ) = = OutPackages . Num ( ) ) ;
check ( OutInfo = = nullptr | | PackagePaths . Num ( ) = = OutInfo - > Num ( ) ) ;
}
Add a rehydration command to the stand alone virtualization tool, making it easier to reverse the effects of asset virtualization. Unlike previous processes, this one does not require that we load the package and will just manipulate the data storaged in the package trailer.
#rb Sebastian.Nordgren
#rnx
#jira UE-156436
#preflight 62c287f9a3568e30664eb94f
### VA Standalone Tool
- We now plan to add much more functionality to the tool than just virtualizing and submitting changelists, so to make this easier I am moving the tool towards a design where it should be fairly easy to add new functionality.
- Added FCommand, which is a base class for adding new functionality, simple derive from FCommand and hook it up at the appropriate locations.
-- In the future it should be possible for new command types to automatically register themselves to be initiated from the command line. There should be no need to edit UnrealVirtualizationToolApp to add a new command but this will be done as an additional work item.
-- At the moment FCommand comes with a number of utility methods to call that cover some common source control commands.
-- The original functionality has not yet been moved to the command system and so the code is a little bit weird at the moment. Updating older code to the new system will be done as an additional work item.
- FProject/FPlugin have been moved to their own code files.
### Rehydrate Command
- The rehydrate command will take a number of packages, check them out of source control and then attempt to virtualize them.
- At the moment the chekout logic is fairly basic, we just check out every package supplied, we don't check if the package is virtualized or not yet. This can be improved in additional work items. Ideally by the end of command the only packages that we have checked out should also be rehydrated.
- At the moment the command can either take a path of a specific package, a path of a directory to find packages in, or a changelist containing packages that should be rehydrated.
- A cleint spec (workspace) can optionally be provided, but if not supplied we will attempt to find a client spec for which to check out the packages.
- Currently we will check out the packages to the default change list.
### Rehydrate process
- Added the rehydration process in it's own code files in the virtualization module. Like the virtualization process this is exposed in a public header file and no via the Core interface which means it is very specific to our module/implementation.
- The process expects that the caller will have checked out any required packages from source control. It will treat being unable to update a package file as an error.
- Added PackageUtils.h/.cpp and moved some of the generic code from the virtualization process code there so that it can be shared by the rehydration process.
### Misc
Moving away from the using things like FPackagePath as that requires that the correct mount points have been registered for a project and at the moment (with the flakiness of FConfig*) it seems that the best idea would be to prefer absolute file paths where possible.
[CL 20982284 by paul chipchase in ue5-main branch]
2022-07-07 06:54:33 -04:00
} // namespace UE::Virtualization
# undef LOCTEXT_NAMESPACE