diff options
| author | Stefan Boberg <[email protected]> | 2021-05-11 21:54:35 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-05-11 21:54:35 +0200 |
| commit | 57384321386f01f6e0f80e3984f08c05a0bb7a42 (patch) | |
| tree | d63d45f885478f23967135788f8a434a596d0b8d /zenserver/projectstore.cpp | |
| parent | Added paths as context to I/O error exception messages (diff) | |
| download | zen-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 'zenserver/projectstore.cpp')
| -rw-r--r-- | zenserver/projectstore.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/zenserver/projectstore.cpp b/zenserver/projectstore.cpp index 0dc0da1ae..c2c8c2421 100644 --- a/zenserver/projectstore.cpp +++ b/zenserver/projectstore.cpp @@ -1057,8 +1057,21 @@ HttpProjectService::HttpProjectService(CasStore& Store, ProjectStore* Projects) IoBuffer Payload = HttpReq.ReadPayload(); + CbPackage::AttachmentResolver Resolver = [&](const IoHash& Hash) -> SharedBuffer { + std::filesystem::path AttachmentPath = Log.TempPath() / Hash.ToHexString(); + + if (IoBuffer Data = IoBufferBuilder::MakeFromFile(AttachmentPath.native().c_str())) + { + return SharedBuffer::Clone(MemoryView(Data.Data(), Data.Size())); + } + else + { + return {}; + } + }; + CbPackage Package; - Package.Load(Payload); + Package.Load(Payload, &UniqueBuffer::Alloc, &Resolver); CbObject Core = Package.GetObject(); |