diff options
| author | mattpetersepic <[email protected]> | 2022-02-18 13:59:27 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-02-18 13:59:27 -0700 |
| commit | b0310f0da356fb9a5e9202f1352cad82e3811b10 (patch) | |
| tree | a406be9d25ee35f8d1920e8fbc4f6d632ea4de96 /zenserver/upstream/upstreamcache.cpp | |
| parent | remote_build: allow path .zips are copied to to be overriden (diff) | |
| download | zen-b0310f0da356fb9a5e9202f1352cad82e3811b10.tar.xz zen-b0310f0da356fb9a5e9202f1352cad82e3811b10.zip | |
Value propagation fix - Read/Write ValueAPI as CompressedBinary type when writing to zen and horde upstreams. Return failure from HandleGetCacheRecord if the requested type does not match the cachetype. (#55)
* Fix bug with getting values PUT to Jupiter as CompressedBinary. When getting CompressedBinary records from Jupiter, they are expected to now be a record with a reference to the compact binary. This has to be accounted for when performing upstream GETs.
* HandleGetCacheRecord: avoid crashing on invalid type, and avoid sending back data that doesn't match the AcceptType.
Diffstat (limited to 'zenserver/upstream/upstreamcache.cpp')
| -rw-r--r-- | zenserver/upstream/upstreamcache.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/zenserver/upstream/upstreamcache.cpp b/zenserver/upstream/upstreamcache.cpp index 5e0f6a297..da0743f0a 100644 --- a/zenserver/upstream/upstreamcache.cpp +++ b/zenserver/upstream/upstreamcache.cpp @@ -177,6 +177,43 @@ namespace detail { { Result = Session.GetDerivedData(CacheKey.Bucket, CacheKey.Hash); } + else if (Type == ZenContentType::kCompressedBinary) + { + Result = Session.GetRef(CacheKey.Bucket, CacheKey.Hash, ZenContentType::kCbObject); + + if (Result.Success) + { + const CbValidateError ValidationResult = ValidateCompactBinary(Result.Response, CbValidateMode::All); + if (Result.Success = ValidationResult == CbValidateError::None; Result.Success) + { + CbObject CacheRecord = LoadCompactBinaryObject(Result.Response); + IoBuffer ContentBuffer; + int NumAttachments = 0; + + CacheRecord.IterateAttachments( + [&Session, &Result, &ContentBuffer, &NumAttachments](CbFieldView AttachmentHash) { + CloudCacheResult AttachmentResult = Session.GetCompressedBlob(AttachmentHash.AsHash()); + Result.Bytes += AttachmentResult.Bytes; + Result.ElapsedSeconds += AttachmentResult.ElapsedSeconds; + Result.ErrorCode = AttachmentResult.ErrorCode; + + if (CompressedBuffer Chunk = CompressedBuffer::FromCompressed(SharedBuffer(AttachmentResult.Response))) + { + Result.Response = AttachmentResult.Response; + ++NumAttachments; + } + else + { + Result.Success = false; + } + }); + if (NumAttachments != 1) + { + Result.Success = false; + } + } + } + } else { const ZenContentType AcceptType = Type == ZenContentType::kCbPackage ? ZenContentType::kCbObject : Type; |