aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/projectstore/projectstore.cpp
diff options
context:
space:
mode:
authorzousar <[email protected]>2023-12-07 15:28:35 -0700
committerGitHub <[email protected]>2023-12-07 15:28:35 -0700
commitb8b4701ec0810b1ea7df4aaf824d26d2bfce73fa (patch)
tree531317314903da569eea099c4a07e721de659b93 /src/zenserver/projectstore/projectstore.cpp
parentUpdate CHANGELOG.md (diff)
parentMerge branch 'main' into zs/get-all-chunk-infos (diff)
downloadzen-b8b4701ec0810b1ea7df4aaf824d26d2bfce73fa.tar.xz
zen-b8b4701ec0810b1ea7df4aaf824d26d2bfce73fa.zip
Merge pull request #593 from EpicGames/zs/get-all-chunk-infos
Zs/get all chunk infos
Diffstat (limited to 'src/zenserver/projectstore/projectstore.cpp')
-rw-r--r--src/zenserver/projectstore/projectstore.cpp42
1 files changed, 29 insertions, 13 deletions
diff --git a/src/zenserver/projectstore/projectstore.cpp b/src/zenserver/projectstore/projectstore.cpp
index c6097dea2..9ba8e3a19 100644
--- a/src/zenserver/projectstore/projectstore.cpp
+++ b/src/zenserver/projectstore/projectstore.cpp
@@ -752,6 +752,21 @@ ProjectStore::Oplog::GetAllChunksInfo()
}
void
+ProjectStore::Oplog::IterateChunkMap(std::function<void(const Oid&, const IoHash&)>&& Fn)
+{
+ RwLock::SharedLockScope _(m_OplogLock);
+ if (!m_Storage)
+ {
+ return;
+ }
+
+ for (const auto& Kv : m_ChunkMap)
+ {
+ Fn(Kv.first, Kv.second);
+ }
+}
+
+void
ProjectStore::Oplog::IterateFileMap(
std::function<void(const Oid&, const std::string_view& ServerPath, const std::string_view& ClientPath)>&& Fn)
{
@@ -2215,9 +2230,9 @@ ProjectStore::GetProjectFiles(const std::string_view ProjectId, const std::strin
}
std::pair<HttpResponseCode, std::string>
-ProjectStore::GetProjectChunks(const std::string_view ProjectId, const std::string_view OplogId, CbObject& OutPayload)
+ProjectStore::GetProjectChunkInfos(const std::string_view ProjectId, const std::string_view OplogId, CbObject& OutPayload)
{
- ZEN_TRACE_CPU("ProjectStore::GetProjectChunks");
+ ZEN_TRACE_CPU("ProjectStore::GetProjectChunkInfos");
using namespace std::literals;
@@ -2235,21 +2250,22 @@ ProjectStore::GetProjectChunks(const std::string_view ProjectId, const std::stri
}
Project->TouchOplog(OplogId);
- std::vector<ProjectStore::Oplog::ChunkInfo> ChunkInfo = FoundLog->GetAllChunksInfo();
+ std::vector<std::pair<Oid, IoHash>> ChunkInfos;
+ FoundLog->IterateChunkMap([&ChunkInfos](const Oid& Id, const IoHash& Hash) { ChunkInfos.push_back({Id, Hash}); });
CbObjectWriter Response;
+ Response.BeginArray("chunkinfos"sv);
- Response.BeginArray("chunks"sv);
- for (ProjectStore::Oplog::ChunkInfo& Info : ChunkInfo)
+ for (const auto& ChunkInfo : ChunkInfos)
{
- Response << Info.ChunkId;
- }
- Response.EndArray();
-
- Response.BeginArray("sizes"sv);
- for (ProjectStore::Oplog::ChunkInfo& Info : ChunkInfo)
- {
- Response << Info.ChunkSize;
+ if (IoBuffer Chunk = FoundLog->FindChunk(ChunkInfo.first))
+ {
+ Response.BeginObject();
+ Response << "id"sv << ChunkInfo.first;
+ Response << "rawhash"sv << ChunkInfo.second;
+ Response << "rawsize"sv << Chunk.GetSize();
+ Response.EndObject();
+ }
}
Response.EndArray();