From 57384321386f01f6e0f80e3984f08c05a0bb7a42 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Tue, 11 May 2021 21:54:35 +0200 Subject: Implemented basic support for marshaling attachments out-of-band with the package payload Currently supported in project store but will also be used for the structured cache Currently, cleanup is missing. Ultimately the intent is that the file used for marshaling will simply be moved into place. --- zencore/compactbinarypackage.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'zencore/compactbinarypackage.cpp') diff --git a/zencore/compactbinarypackage.cpp b/zencore/compactbinarypackage.cpp index 21883f5b1..9eb67ac93 100644 --- a/zencore/compactbinarypackage.cpp +++ b/zencore/compactbinarypackage.cpp @@ -299,12 +299,12 @@ CbPackage::GatherAttachments(const CbFieldViewIterator& Fields, AttachmentResolv } void -CbPackage::Load(IoBuffer& InBuffer, BufferAllocator Allocator) +CbPackage::Load(IoBuffer& InBuffer, BufferAllocator Allocator, AttachmentResolver* Mapper) { MemoryInStream InStream(InBuffer.Data(), InBuffer.Size()); BinaryReader Reader(InStream); - Load(Reader, Allocator); + Load(Reader, Allocator, Mapper); } void @@ -345,7 +345,7 @@ CbPackage::Load(CbFieldIterator& Fields) } void -CbPackage::Load(BinaryReader& Reader, BufferAllocator Allocator) +CbPackage::Load(BinaryReader& Reader, BufferAllocator Allocator, AttachmentResolver* Mapper) { uint8_t StackBuffer[64]; const auto StackAllocator = [&Allocator, &StackBuffer](uint64_t Size) -> UniqueBuffer { @@ -386,6 +386,14 @@ CbPackage::Load(BinaryReader& Reader, BufferAllocator Allocator) } } } + else if (ValueField.IsHash()) + { + const IoHash Hash = ValueField.AsHash(); + + ZEN_ASSERT(Mapper); + + AddAttachment(CbAttachment((*Mapper)(Hash), Hash)); + } else { ZEN_ASSERT(ValueField.IsObject(), "Expected Object, Binary, or Null field when loading a package"); -- cgit v1.2.3