From d65be761d6c0b7ef74e854862514de55db6a2722 Mon Sep 17 00:00:00 2001 From: Per Larsson Date: Sun, 14 Nov 2021 08:51:29 +0100 Subject: Parse chunk ID from chunk request. --- zenserver/cache/structuredcache.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'zenserver/cache/structuredcache.cpp') diff --git a/zenserver/cache/structuredcache.cpp b/zenserver/cache/structuredcache.cpp index feb8efb2e..79d370740 100644 --- a/zenserver/cache/structuredcache.cpp +++ b/zenserver/cache/structuredcache.cpp @@ -1000,7 +1000,7 @@ HttpStructuredCacheService::HandleRpcGetCachePayloads(zen::HttpServerRequest& Re CbObjectView RequestObject = RequestView.AsObjectView(); CbObjectView KeyObject = RequestObject["Key"sv].AsObjectView(); const CacheKey Key = CacheKey::Create(KeyObject["Bucket"sv].AsString(), KeyObject["Hash"sv].AsHash()); - const IoHash ChunkId = IoHash::Zero; + const IoHash ChunkId = RequestObject["ChunkId"sv].AsHash(); const Oid PayloadId = RequestObject["PayloadId"sv].AsObjectId(); const uint64_t RawOffset = RequestObject["RawoffSet"sv].AsUInt64(); const uint64_t RawSize = RequestObject["RawSize"sv].AsUInt64(); @@ -1016,12 +1016,13 @@ HttpStructuredCacheService::HandleRpcGetCachePayloads(zen::HttpServerRequest& Re Chunks.resize(ChunkRequests.size()); - // Try to find the uncompressed raw hash from the payload ID. + // Unreal uses a 12 byte ID to address cache record payloads. When the uncompressed hash (ChunkId) + // is missing, load the cache record and try to find the raw hash from the payload ID. { const auto GetChunkIdFromPayloadId = [](CbObjectView Record, const Oid& PayloadId) -> IoHash { - if (CbObjectView ValueObject = Record["Value"].AsObjectView()) + if (CbObjectView ValueObject = Record["Value"sv].AsObjectView()) { - const Oid Id = ValueObject["Id"].AsObjectId(); + const Oid Id = ValueObject["Id"sv].AsObjectId(); if (Id == PayloadId) { return ValueObject["RawHash"sv].AsHash(); @@ -1031,7 +1032,7 @@ HttpStructuredCacheService::HandleRpcGetCachePayloads(zen::HttpServerRequest& Re for (CbFieldView AttachmentView : Record["Attachments"sv]) { CbObjectView AttachmentObject = AttachmentView.AsObjectView(); - const Oid Id = AttachmentObject["Id"].AsObjectId(); + const Oid Id = AttachmentObject["Id"sv].AsObjectId(); if (Id == PayloadId) { @@ -1049,6 +1050,11 @@ HttpStructuredCacheService::HandleRpcGetCachePayloads(zen::HttpServerRequest& Re for (CacheChunkRequest& ChunkRequest : ChunkRequests) { + if (ChunkRequest.ChunkId != IoHash::Zero) + { + continue; + } + if (ChunkRequest.Key != CurrentKey) { CurrentKey = ChunkRequest.Key; -- cgit v1.2.3