aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/projectstore/projectstore.cpp
diff options
context:
space:
mode:
authorzousar <[email protected]>2025-03-25 15:14:47 -0600
committerzousar <[email protected]>2025-03-25 15:14:47 -0600
commitcc4d4751201bbf83531ea9919f242bfac3add8d3 (patch)
treec477c6278796c0246c9ad7767b920794e08fbb18 /src/zenserver/projectstore/projectstore.cpp
parentChangelog (diff)
downloadzen-cc4d4751201bbf83531ea9919f242bfac3add8d3.tar.xz
zen-cc4d4751201bbf83531ea9919f242bfac3add8d3.zip
Moved AcceptType Handling From ProjectStore To HttpProjectStore
Diffstat (limited to 'src/zenserver/projectstore/projectstore.cpp')
-rw-r--r--src/zenserver/projectstore/projectstore.cpp61
1 files changed, 3 insertions, 58 deletions
diff --git a/src/zenserver/projectstore/projectstore.cpp b/src/zenserver/projectstore/projectstore.cpp
index 1132e458e..ea3f2aad9 100644
--- a/src/zenserver/projectstore/projectstore.cpp
+++ b/src/zenserver/projectstore/projectstore.cpp
@@ -4770,7 +4770,6 @@ std::pair<HttpResponseCode, std::string>
ProjectStore::GetChunk(const std::string_view ProjectId,
const std::string_view OplogId,
const std::string_view Cid,
- ZenContentType AcceptType,
IoBuffer& OutChunk,
uint64_t* OptionalInOutModificationTag)
{
@@ -4812,51 +4811,7 @@ ProjectStore::GetChunk(const std::string_view ProjectId,
}
}
- if (AcceptType == ZenContentType::kUnknownContentType || AcceptType == ZenContentType::kBinary || AcceptType == ZenContentType::kJSON ||
- AcceptType == ZenContentType::kYAML || AcceptType == ZenContentType::kCbObject)
- {
- CompressedBuffer Compressed = CompressedBuffer::FromCompressedNoValidate(std::move(OutChunk));
- IoBuffer DecompressedBuffer = Compressed.Decompress().AsIoBuffer();
-
- if (AcceptType == ZenContentType::kJSON || AcceptType == ZenContentType::kYAML || AcceptType == ZenContentType::kCbObject)
- {
- CbValidateError CbErr = ValidateCompactBinary(DecompressedBuffer.GetView(), CbValidateMode::Default);
- if (!!CbErr)
- {
- return {HttpResponseCode::NotAcceptable, fmt::format("chunk - '{}' WRONGTYPE", Cid)};
- }
-
- if (AcceptType == HttpContentType::kJSON || AcceptType == HttpContentType::kYAML)
- {
- CbObject ContainerObject = LoadCompactBinaryObject(DecompressedBuffer);
- ExtendableStringBuilder<1024> Sb;
- if (AcceptType == HttpContentType::kJSON)
- {
- ContainerObject.ToJson(Sb);
- }
- else if (AcceptType == HttpContentType::kYAML)
- {
- ContainerObject.ToYaml(Sb);
- }
- IoBuffer SerializedBuffer(IoBuffer::Clone, Sb.Data(), Sb.Size());
- OutChunk = SerializedBuffer;
- }
- else
- {
- OutChunk = DecompressedBuffer;
- }
- OutChunk.SetContentType(AcceptType);
- }
- else
- {
- OutChunk = DecompressedBuffer;
- OutChunk.SetContentType(ZenContentType::kBinary);
- }
- }
- else
- {
- OutChunk.SetContentType(ZenContentType::kCompressedBinary);
- }
+ OutChunk.SetContentType(ZenContentType::kCompressedBinary);
return {HttpResponseCode::OK, {}};
}
@@ -8551,12 +8506,7 @@ TEST_CASE("project.store.partial.read")
uint64_t ModificationTag = 0;
IoBuffer Chunk;
CHECK(ProjectStore
- .GetChunk("proj1"sv,
- "oplog1"sv,
- Attachments[OpIds[1]][0].second.DecodeRawHash().ToHexString(),
- HttpContentType::kCompressedBinary,
- Chunk,
- &ModificationTag)
+ .GetChunk("proj1"sv, "oplog1"sv, Attachments[OpIds[1]][0].second.DecodeRawHash().ToHexString(), Chunk, &ModificationTag)
.first == HttpResponseCode::OK);
IoHash RawHash;
uint64_t RawSize;
@@ -8565,12 +8515,7 @@ TEST_CASE("project.store.partial.read")
CHECK(ModificationTag != 0);
CHECK(ProjectStore
- .GetChunk("proj1"sv,
- "oplog1"sv,
- Attachments[OpIds[1]][0].second.DecodeRawHash().ToHexString(),
- HttpContentType::kCompressedBinary,
- Chunk,
- &ModificationTag)
+ .GetChunk("proj1"sv, "oplog1"sv, Attachments[OpIds[1]][0].second.DecodeRawHash().ToHexString(), Chunk, &ModificationTag)
.first == HttpResponseCode::NotModified);
}