2021-09-28 04:00:33 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "StorageServerPackageStore.h"
|
|
|
|
|
#include "IO/IoContainerHeader.h"
|
|
|
|
|
#include "IO/IoDispatcher.h"
|
|
|
|
|
#include "StorageServerConnection.h"
|
2021-10-27 15:14:40 -04:00
|
|
|
#include "Serialization/MemoryReader.h"
|
2021-09-28 04:00:33 -04:00
|
|
|
|
|
|
|
|
#if !UE_BUILD_SHIPPING
|
|
|
|
|
|
|
|
|
|
FStorageServerPackageStore::FStorageServerPackageStore(FStorageServerConnection& Connection)
|
|
|
|
|
{
|
|
|
|
|
FIoChunkId HeaderChunkId = CreateIoChunkId(FIoContainerId::FromName(TEXT("global")).Value(), 0, EIoChunkType::ContainerHeader);
|
2021-10-27 15:14:40 -04:00
|
|
|
Connection.ReadChunkRequest(HeaderChunkId, 0, uint64(-1), [this](FStorageServerResponse& Response)
|
2021-09-28 04:00:33 -04:00
|
|
|
{
|
2021-10-27 15:14:40 -04:00
|
|
|
FIoBuffer Chunk;
|
|
|
|
|
if (Response.SerializeChunk(Chunk))
|
2021-09-28 04:00:33 -04:00
|
|
|
{
|
2021-10-27 15:14:40 -04:00
|
|
|
FMemoryReaderView Ar(MakeArrayView(reinterpret_cast<const uint8*>(Chunk.Data()), Chunk.DataSize()));
|
|
|
|
|
|
2021-09-28 04:00:33 -04:00
|
|
|
FIoContainerHeader ContainerHeader;
|
2021-10-27 15:14:40 -04:00
|
|
|
Ar << ContainerHeader;
|
2021-09-28 04:00:33 -04:00
|
|
|
StoreEntriesData = MoveTemp(ContainerHeader.StoreEntries);
|
|
|
|
|
StoreEntriesMap.Reserve(ContainerHeader.PackageCount);
|
|
|
|
|
TArrayView<const FFilePackageStoreEntry> StoreEntries(reinterpret_cast<const FFilePackageStoreEntry*>(StoreEntriesData.GetData()), ContainerHeader.PackageCount);
|
|
|
|
|
int32 Index = 0;
|
|
|
|
|
for (const FFilePackageStoreEntry& StoreEntry : StoreEntries)
|
|
|
|
|
{
|
|
|
|
|
const FPackageId& PackageId = ContainerHeader.PackageIds[Index];
|
|
|
|
|
check(PackageId.IsValid());
|
|
|
|
|
StoreEntriesMap.FindOrAdd(PackageId, &StoreEntry);
|
|
|
|
|
++Index;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FStorageServerPackageStore::DoesPackageExist(FPackageId PackageId)
|
|
|
|
|
{
|
|
|
|
|
return PackageId.IsValid() && StoreEntriesMap.Contains(PackageId);
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-12 21:21:22 -04:00
|
|
|
EPackageStoreEntryStatus FStorageServerPackageStore::GetPackageStoreEntry(FPackageId PackageId, FPackageStoreEntry& OutPackageStoreEntry)
|
2021-09-28 04:00:33 -04:00
|
|
|
{
|
|
|
|
|
const FFilePackageStoreEntry* FindEntry = StoreEntriesMap.FindRef(PackageId);
|
2021-10-12 21:21:22 -04:00
|
|
|
if (FindEntry)
|
2021-09-28 04:00:33 -04:00
|
|
|
{
|
2021-10-12 21:21:22 -04:00
|
|
|
OutPackageStoreEntry.ExportInfo.ExportCount = FindEntry->ExportCount;
|
|
|
|
|
OutPackageStoreEntry.ExportInfo.ExportBundleCount = FindEntry->ExportBundleCount;
|
|
|
|
|
OutPackageStoreEntry.ImportedPackageIds = MakeArrayView(FindEntry->ImportedPackages.Data(), FindEntry->ImportedPackages.Num());
|
|
|
|
|
OutPackageStoreEntry.ShaderMapHashes = MakeArrayView(FindEntry->ShaderMapHashes.Data(), FindEntry->ShaderMapHashes.Num());
|
|
|
|
|
return EPackageStoreEntryStatus::Ok;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return EPackageStoreEntryStatus::Missing;
|
|
|
|
|
}
|
2021-09-28 04:00:33 -04:00
|
|
|
}
|
|
|
|
|
|
2021-10-27 15:14:40 -04:00
|
|
|
#endif
|