diff options
| author | Stefan Boberg <[email protected]> | 2021-08-20 13:51:39 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-08-20 13:51:39 +0200 |
| commit | d88262efac17b956600c85a2ba5e70c66937eb96 (patch) | |
| tree | 52352a8183bd1e528d7380b82926fe13bfbdabeb /zenserver/projectstore.cpp | |
| parent | Renamed CompactBinaryAttachment to ObjectAttachment to mimic UE (see CL16510518) (diff) | |
| download | zen-d88262efac17b956600c85a2ba5e70c66937eb96.tar.xz zen-d88262efac17b956600c85a2ba5e70c66937eb96.zip | |
CL16570338: CompactBinary: Added validation to LoadCompactBinary and removed asserts from the other load functions
Diffstat (limited to 'zenserver/projectstore.cpp')
| -rw-r--r-- | zenserver/projectstore.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/zenserver/projectstore.cpp b/zenserver/projectstore.cpp index 750ecdb6a..534983347 100644 --- a/zenserver/projectstore.cpp +++ b/zenserver/projectstore.cpp @@ -530,15 +530,34 @@ ProjectStore::Oplog::AppendNewOplogEntry(CbPackage OpPackage) // Persist attachments + uint64_t AttachmentBytes = 0; + uint64_t NewAttachmentBytes = 0; + auto Attachments = OpPackage.GetAttachments(); for (const auto& Attach : Attachments) { - IoBuffer AttachmentData = Attach.AsBinaryView().AsIoBuffer(); - m_CasStore.InsertChunk(AttachmentData, Attach.GetHash()); + IoBuffer AttachmentData = Attach.AsBinaryView().AsIoBuffer(); + CasStore::InsertResult Result = m_CasStore.InsertChunk(AttachmentData, Attach.GetHash()); + + const uint64_t AttachmentSize = AttachmentData.Size(); + + if (Result.New) + { + NewAttachmentBytes += AttachmentSize; + } + + AttachmentBytes += AttachmentSize; } - return RegisterOplogEntry(Core, OpEntry, kUpdateNewEntry); + const uint32_t EntryId = RegisterOplogEntry(Core, OpEntry, kUpdateNewEntry); + + Log().debug("oplog entry #{} attachments: {}B new, {}B total", + EntryId, + zen::NiceBytes(NewAttachmentBytes), + zen::NiceBytes(AttachmentBytes)); + + return EntryId; } ////////////////////////////////////////////////////////////////////////// @@ -1367,7 +1386,10 @@ HttpProjectService::HttpProjectService(CasStore& Store, ProjectStore* Projects) }; CbPackage Package; - Package.Load(Payload, &UniqueBuffer::Alloc, &Resolver); + if (!Package.TryLoad(Payload, &UniqueBuffer::Alloc, &Resolver)) + { + return HttpReq.WriteResponse(HttpResponse::BadRequest, HttpContentType::kText, "Invalid package"); + } if (!IsValid) { |