diff options
Diffstat (limited to 'zenserver/cache/structuredcache.cpp')
| -rw-r--r-- | zenserver/cache/structuredcache.cpp | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/zenserver/cache/structuredcache.cpp b/zenserver/cache/structuredcache.cpp index 875dbf67b..2675590e0 100644 --- a/zenserver/cache/structuredcache.cpp +++ b/zenserver/cache/structuredcache.cpp @@ -1043,38 +1043,49 @@ HttpStructuredCacheService::HandleRpcGetCachePayloads(zen::HttpServerRequest& Re // 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"sv].AsObjectView()) + if (PayloadId) { - const Oid Id = ValueObject["Id"sv].AsObjectId(); - if (Id == PayloadId) + // A valid PayloadId indicates that the caller is searching for a Payload in a Record + // that was Put with ICacheStore::Put + for (CbFieldView ValueView : Record["Values"sv]) { - return ValueObject["RawHash"sv].AsHash(); - } - } + CbObjectView ValueObject = ValueView.AsObjectView(); + const Oid Id = ValueObject["Id"sv].AsObjectId(); - for (CbFieldView ValueView : Record["Values"sv]) - { - CbObjectView ValueObject = ValueView.AsObjectView(); - const Oid Id = ValueObject["Id"sv].AsObjectId(); + if (Id == PayloadId) + { + return ValueObject["RawHash"sv].AsHash(); + } + } - if (Id == PayloadId) + // Legacy fields from previous version of CacheRecord serialization: + if (CbObjectView ValueObject = Record["Value"sv].AsObjectView()) { - return ValueObject["RawHash"sv].AsHash(); + const Oid Id = ValueObject["Id"sv].AsObjectId(); + if (Id == PayloadId) + { + return ValueObject["RawHash"sv].AsHash(); + } } - } - for (CbFieldView AttachmentView : Record["Attachments"sv]) - { - CbObjectView AttachmentObject = AttachmentView.AsObjectView(); - const Oid Id = AttachmentObject["Id"sv].AsObjectId(); - - if (Id == PayloadId) + for (CbFieldView AttachmentView : Record["Attachments"sv]) { - return AttachmentObject["RawHash"sv].AsHash(); + CbObjectView AttachmentObject = AttachmentView.AsObjectView(); + const Oid Id = AttachmentObject["Id"sv].AsObjectId(); + + if (Id == PayloadId) + { + return AttachmentObject["RawHash"sv].AsHash(); + } } + return IoHash::Zero; + } + else + { + // An invalid PayloadId indicates that the caller is requesting a Value that + // was Put with ICacheStore::PutValue + return Record["RawHash"sv].AsHash(); } - - return IoHash::Zero; }; CacheKey CurrentKey = CacheKey::Empty; |