aboutsummaryrefslogtreecommitdiff
path: root/zenserver/projectstore.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-09-14 15:42:15 +0200
committerStefan Boberg <[email protected]>2021-09-14 15:42:15 +0200
commit87c5c1496a97c6ada525895414163ad4ab70a23e (patch)
treeff720cd0bf26acfdfb3cb592571d975c4a58cea9 /zenserver/projectstore.cpp
parentImplemented intended package streaming API flow (but currently it "streams" f... (diff)
downloadzen-87c5c1496a97c6ada525895414163ad4ab70a23e.tar.xz
zen-87c5c1496a97c6ada525895414163ad4ab70a23e.zip
oplog: added handling of new attachment types
Diffstat (limited to 'zenserver/projectstore.cpp')
-rw-r--r--zenserver/projectstore.cpp31
1 files changed, 28 insertions, 3 deletions
diff --git a/zenserver/projectstore.cpp b/zenserver/projectstore.cpp
index ffed50e9a..2bbc1dce3 100644
--- a/zenserver/projectstore.cpp
+++ b/zenserver/projectstore.cpp
@@ -542,8 +542,30 @@ ProjectStore::Oplog::AppendNewOplogEntry(CbPackage OpPackage)
for (const auto& Attach : Attachments)
{
- IoBuffer AttachmentData = Attach.AsBinary().AsIoBuffer();
- CasStore::InsertResult Result = m_CasStore.InsertChunk(AttachmentData, Attach.GetHash());
+ IoBuffer AttachmentData;
+
+ if (Attach.IsBinary())
+ {
+ AttachmentData = Attach.AsBinary().AsIoBuffer();
+ }
+ else if (Attach.IsCompressedBinary())
+ {
+ ZEN_NOT_IMPLEMENTED("Compressed binary attachments are currently not supported for oplogs");
+
+ AttachmentData = Attach.AsCompressedBinary().GetCompressed().Flatten().AsIoBuffer();
+ }
+ else if (Attach.IsObject())
+ {
+ AttachmentData = Attach.AsObject().GetBuffer().AsIoBuffer();
+ }
+ else
+ {
+ ZEN_NOT_IMPLEMENTED("Unknown attachment type");
+ }
+
+ ZEN_ASSERT(AttachmentData);
+
+ CasStore::InsertResult Result = m_CasStore.InsertChunk(AttachmentData, Attach.GetHash());
const uint64_t AttachmentSize = AttachmentData.Size();
@@ -1387,8 +1409,11 @@ HttpProjectService::HttpProjectService(CasStore& Store, ProjectStore* Projects)
};
CbPackage Package;
- if (!Package.TryLoad(Payload, &UniqueBuffer::Alloc, &Resolver))
+
+ if (!legacy::TryLoadCbPackage(Package, Payload, &UniqueBuffer::Alloc, &Resolver))
{
+ m_Log.error("Received malformed package!");
+
return HttpReq.WriteResponse(HttpResponseCode::BadRequest, HttpContentType::kText, "Invalid package");
}