diff options
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) { |