diff options
| author | Stefan Boberg <[email protected]> | 2021-09-16 14:05:02 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-16 14:05:02 +0200 |
| commit | 397067ff20be5d1441cc1d8103913484e15da0ca (patch) | |
| tree | d2dba835fa1c46eee9915c1a38d83ad3e202216b /zenserver/compute/apply.cpp | |
| parent | Fixed up mesh logging (diff) | |
| download | zen-397067ff20be5d1441cc1d8103913484e15da0ca.tar.xz zen-397067ff20be5d1441cc1d8103913484e15da0ca.zip | |
Fixed marshaling of outputs including sanity checks, logging
Diffstat (limited to 'zenserver/compute/apply.cpp')
| -rw-r--r-- | zenserver/compute/apply.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/zenserver/compute/apply.cpp b/zenserver/compute/apply.cpp index 2c3243655..e40c6918d 100644 --- a/zenserver/compute/apply.cpp +++ b/zenserver/compute/apply.cpp @@ -806,11 +806,14 @@ HttpFunctionService::ExecAction(const WorkerDesc& Worker, CbObject Action) CbPackage OutputPackage; CbObject Output = zen::LoadCompactBinaryObject(OutputData.Data[0]); + uint64_t TotalAttachmentBytes = 0; + uint64_t TotalRawAttachmentBytes = 0; + Output.IterateAttachments([&](CbFieldView Field) { IoHash Hash = Field.AsHash(); std::filesystem::path OutputPath{SandboxPath / "Outputs" / Hash.ToHexString()}; - FileContents ChunkData = zen::ReadFile(SandboxPath / "build.output"); + FileContents ChunkData = zen::ReadFile(OutputPath); if (ChunkData.ErrorCode) { @@ -819,12 +822,27 @@ HttpFunctionService::ExecAction(const WorkerDesc& Worker, CbObject Action) ZEN_ASSERT(OutputData.Data.size() == 1); - CbAttachment Attachment(CompressedBuffer::FromCompressed(SharedBuffer(ChunkData.Data[0]))); + CompressedBuffer AttachmentBuffer = CompressedBuffer::FromCompressed(SharedBuffer(ChunkData.Data[0])); + + if (!AttachmentBuffer) + { + throw std::runtime_error("Invalid output encountered (not valid CompressedBuffer format)"); + } + + TotalAttachmentBytes += AttachmentBuffer.GetCompressedSize(); + TotalRawAttachmentBytes += AttachmentBuffer.GetCompressedSize(); + + CbAttachment Attachment(AttachmentBuffer); OutputPackage.AddAttachment(Attachment); }); OutputPackage.SetObject(Output); + ZEN_DEBUG("Action completed with {} attachments ({} compressed, {} uncompressed)", + OutputPackage.GetAttachments().size(), + NiceBytes(TotalAttachmentBytes), + NiceBytes(TotalRawAttachmentBytes)); + return OutputPackage; } |