aboutsummaryrefslogtreecommitdiff
path: root/zencore/compactbinarypackage.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-05-11 21:54:35 +0200
committerStefan Boberg <[email protected]>2021-05-11 21:54:35 +0200
commit57384321386f01f6e0f80e3984f08c05a0bb7a42 (patch)
treed63d45f885478f23967135788f8a434a596d0b8d /zencore/compactbinarypackage.cpp
parentAdded paths as context to I/O error exception messages (diff)
downloadzen-57384321386f01f6e0f80e3984f08c05a0bb7a42.tar.xz
zen-57384321386f01f6e0f80e3984f08c05a0bb7a42.zip
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.
Diffstat (limited to 'zencore/compactbinarypackage.cpp')
-rw-r--r--zencore/compactbinarypackage.cpp14
1 files changed, 11 insertions, 3 deletions
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");