Okay, I solved it!
I was stepping through the code until I ended up in the
class FChunkDownloader::FPakMountWork : public FNonAbandonableTask
where in the void DoWork() function there is the following if statement:
if (FCoreDelegates::MountPak.IsBound())
which was not the case. So you can’t get past that if statement.
So the solution is to make sure the MountPak delegate is bound. To do so define this in your class:
TSharedPtr<FPakPlatformFile> PakPlatform;
class IPlatformFile* OriginalPlatform;
and before you do your patch operation:
// Store the platform file currently set
OriginalPlatform = &FPlatformFileManager::Get().GetPlatformFile();
// See if the pak platform is valid
if (!PakPlatform)
{
PakPlatform = MakeShareable<FPakPlatformFile>(new FPakPlatformFile());
}
// Initialize the pak platform file. This is where the MountPak delegate gets set.
PakPlatform->Initialize(&FPlatformFileManager::Get().GetPlatformFile(), TEXT(""));
// Set initialized Pak platform file
FPlatformFileManager::Get().SetPlatformFile(*PakPlatform.Get());
Now you will pass the if statement mentioned before because the MountPak delegate is set.
What you did is to tell the platform file system to treat Pak files now.
Important: After patching you need to set the original platform file again:
// Set the original platform file again after doing the pak file update.
FPlatformFileManager::Get().SetPlatformFile(*OriginalPlatform);
Otherwise the system thinks it should still treat pak files even if that is not the case anymore. The system can crash if you don’t set back the original platform file.
I hope this helps
For further explanations please have a look here. That link gave me the solution after digging through engine code for days and days:
https://programmer.ink/think/ue4-pak-package-hot-update.html